Session replication in Tomcat with Hazelcast

When running Alfresco Share in a clustered environment, it’s recommended to use sticky sessions. Sticky sessions make sure that a user stays on the same server throughout the users interaction with Alfresco Share. There is one occasion where the user experience fails and that is when the server the user currently uses goes down for some reason. The next action in Alfresco Share the user executes will lead to a login screen for the user. This can be prevented if the session is replicated to all the other Alfresco Share servers in the cluster. There are multiple ways to achieve this. One way is to use memcached or couchbase as a session storage. Another is to use Hazelcast, the clustering solution already used by Alfresco.

In order to simplify deployment and upgrades, injecting stuff into the web.xml file for Alfresco Share is done as a post-processing step when installing Alfresco. This is achieved with an ant task, xmltask.

Installation steps (Ubuntu 12.04)

  • sudo apt-get install ant
  • sudo curl -o /usr/share/java/xmltask-1.16.1.jar -L http://downloads.sourceforge.net/project/xmltask/xmltask/1.16.1/xmltask.jar?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fxmltask%2Ffiles%2Fxmltask%2F1.16.1%2F&ts=1428909584&use_mirror=softlayer-ams
  • sudo ln -s /usr/share/java/xmltask-1.16.1.jar /usr/share/java/xmltask.jar
  • sudo ln -s /usr/share/java/xmltask.jar /usr/share/ant/lib/xmltask.jar
  • Create an ant build script that injects the correct filter, filter-mapping and session-listener elements into the web.xml.
<project name="post-process-share" default="modify" basedir=".">

  <taskdef name="xmltask" classname="com.oopsconsultancy.xmltask.ant.XmlTask" />

  <target name="modify">
    <xmltask source="./tomcat-share/webapps/share/WEB-INF/web.xml"
             dest="./tomcat-share/webapps/share/WEB-INF/web.xml"
             failWithoutMatch="true">

      <insert path="/:web-app/:filter[1]" position="before">
        <![CDATA[
        <filter>
          <filter-name>hazelcast-filter</filter-name>
          <filter-class>com.hazelcast.web.WebFilter</filter-class>
          <init-param>
            <param-name>map-name</param-name>
            <param-value>slingshot-sessions</param-value>
          </init-param>
          <init-param>
            <param-name>sticky-session</param-name>
            <param-value>false</param-value>
          </init-param>
          <init-param>
            <param-name>debug</param-name>
            <param-value>true</param-value>
          </init-param>
          <init-param>
            <param-name>use-client</param-name>
            <param-value>true</param-value>
          </init-param>
          <init-param>
            <param-name>instance-name</param-name>
            <param-value>slingshot</param-value>
          </init-param>
          <init-param>
            <param-name>client-config-location</param-name>
            <param-value>hazelcast-custom-client.properties</param-value>
          </init-param>
        </filter>
        ]]>
      </insert>

      <insert path="/:web-app/:filter-mapping[1]" position="before">
        <![CDATA[
        <filter-mapping>
          <filter-name>hazelcast-filter</filter-name>
          <url-pattern>/*</url-pattern>
          <dispatcher>FORWARD</dispatcher>
          <dispatcher>INCLUDE</dispatcher>
          <dispatcher>REQUEST</dispatcher>
        </filter-mapping>
        ]]>
      </insert>

      <insert path="/:web-app/:listener" position="before">
        <![CDATA[
        <listener>
          <listener-class>com.hazelcast.web.SessionListener</listener-class>
        </listener>
        ]]>
      </insert>

    </xmltask>
  </target>

</project>
  • In the install script, do something like
echo "Executing post-process steps . . ."
# unpack the share.war file in order to to post-process the web.xml
unzip -qq $ALFRESCO_TOMCAT_HOME_SHARE/webapps/share.war -d $ALFRESCO_TOMCAT_HOME_SHARE/webapps/share
# execute the ant build script
ant -q -f build-post-process.xml
echo ""
  • Create a hazelcast client settings file (hazelcast-custom-client.properties) and place it in the tomcat/shared/classes directory.
# the group name, password and port configured in the custom-slingshot-application-context.xml
hazelcast.client.group.name = slingshot
hazelcast.client.group.pass = alfresco
hazelcast.client.addresses  = localhost:5801
  • Two new dependencies must be added in order for the WebFilter and SessionListener to work with the above configuration. If using Maven, do this:
<!-- Hazelcast VM and Client added to have session replication -->
<dependency>
  <groupId>com.hazelcast</groupId>
  <artifactId>hazelcast-wm</artifactId>
  <version>2.4</version>
</dependency>

<!-- There is a bug in ClientConfigBuilder that's fixed in 2.4.1 -->
<dependency>
  <groupId>com.hazelcast</groupId>
  <artifactId>hazelcast-client</artifactId>
  <version>2.4.1</version>
</dependency>

With this setup in place, each and every server that’s a member in the cluster will replicate it’s sessions to all the other members. If (when…) one server goes down all users are transparently moved to a new server.

This entry was posted in Alfresco, cluster, share. Bookmark the permalink.

162 Responses to Session replication in Tomcat with Hazelcast

  1. see pron says:

    2ubUcv I think this is a real great post.Really thank you! Cool.

  2. This website certainly has all of the information and facts I wanted about this subject and didn at know who to ask.

  3. to read more says:

    Right now it sounds like Movable Type is the top blogging platform out there right now. (from what I ave read) Is that what you are using on your blog?

  4. Just got a Blogger account, it works good, but how do I find different users blogs I like with search. I remember there is a way, but I am not seeing it now. Thanks for your help..

  5. upper! Come on over and consult with my website.

  6. read more says:

    Really informative blog.Really looking forward to read more. Fantastic.

  7. you will have an amazing weblog here! would you wish to make some invite posts on my weblog?

  8. This is a really good tip especially to those new to the blogosphere. Simple but very precise info Appreciate your sharing this one. A must read post!

  9. blog9ja says:

    Very good post.Really looking forward to read more. Really Cool.

  10. make my blog jump out. Please let me know where you got your design.

  11. Very informative blog post.Really looking forward to read more. Great.

  12. Only wanna remark that you have a very nice internet site , I the design and style it actually stands out.

  13. some really great content on this site, regards for contribution.

  14. This unique blog is really cool as well as informative. I have chosen a lot of helpful things out of this amazing blog. I ad love to go back every once in a while. Thanks!

  15. Nice blog here! Additionally your website loads up very fast! What web host are you the usage of? Can I get your associate link to your host? I want my website loaded up as fast as yours lol

  16. of the subjects you write related to here. Again, awesome web site!

  17. I really liked your article.Really thank you! Really Cool.

  18. vi da ca sau says:

    You are my inspiration, I have few blogs and often run out from post . Analyzing humor is like dissecting a frog. Few people are interested and the frog dies of it. by E. B. White.

  19. Share this says:

    This blog is without a doubt educating and besides amusing. I have found a bunch of handy stuff out of this source. I ad love to come back again soon. Thanks a lot!

  20. Thanks for sharing, this is a fantastic article.Thanks Again. Cool.

  21. this topic. You realize so much its almost hard to argue with you (not

  22. Simply wanna input that you have a very decent website , I like the style and design it actually stands out.

  23. just go to says:

    liberals liberals liberals employed by non-public enterprise (or job creators).

  24. Share says:

    It as remarkable to pay a quick visit this web site and reading the views of all friends concerning this paragraph, while I am also eager of getting experience.

  25. concordium says:

    Looking forward to reading more. Great article post.Really thank you! Awesome.

  26. Wow, great article.Thanks Again. Fantastic.

  27. Thanks again for the article post. Keep writing.

  28. previous to and you are just too fantastic. I really like what

  29. You produce a strong financially viable decision whenever you decide to purchase a motor vehicle with a

  30. Im obliged for the article. Much obliged.

  31. to read more says:

    pretty beneficial material, overall I believe this is worth a bookmark, thanks

  32. Mantra Yoga says:

    There is evidently a bundle to identify about this. I consider you made some nice points in features also.

  33. Lung Health says:

    Many thanks for sharing this first-class post. Very inspiring! (as always, btw)

  34. Very neat post.Really thank you! Will read on

  35. Racecar says:

    I think this is a real great post.Really thank you! Much obliged.

  36. go says:

    victor cruz jersey have been decided by field goals. However, there are many different levels based on ability.

  37. home page says:

    Really informative blog post.Really looking forward to read more. Great.

  38. click here says:

    Very informative article post.Really thank you! Fantastic.

  39. Major thanks for the blog post.Much thanks again. Will read on

  40. Very nice blog post. I definitely love this website. Keep writing!

  41. Kallos says:

    Motyvacija kaip tvai galt padti savo vaikams Gimtasis odis

  42. This blog is obviously entertaining and besides amusing. I have found many useful stuff out of this amazing blog. I ad love to visit it again and again. Thanks a lot!

  43. There is perceptibly a bundle to identify about this. I feel you made various good points in features also.

  44. Candace says:

    Wow! This could be one particular of the most helpful blogs We ave ever arrive across on this subject. Actually Excellent. I am also an expert in this topic so I can understand your effort.

  45. beat it up says:

    Thanks for writing such a interesting article, I stumbled onto your blog and read a few posts. I like your style of writing

  46. The pursuing are the different types of lasers we will be thinking about for the purposes I pointed out above:

  47. I think, that you commit an error. I can defend the position. Write to me in PM, we will communicate.

  48. picked up something new from right here. I did however expertise a few technical points using this web site, since I experienced to reload the site many times previous to I could

  49. Search engine optimization (SEO) is the process of affecting the visibility of a website or a web page

  50. this website says:

    You created some decent points there. I looked more than the online world for the issue and positioned many people goes as well as together with your web site.

  51. it is part of it. With a boy, you will have

  52. Some truly good stuff on this website , I it.

  53. blue nike says:

    Thanks-a-mundo for the blog article.Much thanks again. Really Great.

  54. value says:

    This is one awesome article post.Much thanks again. Fantastic.

  55. Utterly composed written content , appreciate it for information.

  56. You are my intake , I have few web logs and sometimes run out from to brand.

  57. Waec exam says:

    This website was how do I say it? Relevant!! Finally I ave found something which helped me. Thanks a lot!

  58. Really appreciate you sharing this article.Really looking forward to read more. Want more.

  59. Keep up the great piece of work, I read few content on this web site and I think that your web blog is rattling interesting and contains lots of good info.

  60. Perfect work you have done, this internet site is really cool with superb info.

  61. Some genuinely nice stuff on this site, I like it.

  62. Thank you for another fantastic post. Where else could anybody get that type of information in such an ideal way of writing? I ave a presentation next week, and I am on the look for such information.

  63. Say, you got a nice article post.Much thanks again. Will read on

  64. If I start a blog on Myspace, will it get listed in search engines like Google? If so, is there a way to keep them from being crawled?.. Thank you.

  65. repair service, routine maintenance and electricity conservation of economic roofing systems will probably be as cost-effective as is possible. And using this

  66. Open Heavens says:

    The Hargrove clip was part of the biggest obstacles for Michael Kors Handbags Outlet and it

  67. This page definitely has all of the info I needed about this subject and didn at know who to ask.

  68. I value the blog.Much thanks again. Fantastic.

  69. I truly love this blog article.Thanks Again and again. Will read on

  70. Very informative article post.Really looking forward to read more. Great.

  71. When I look at your blog in Safari, it looks fine but

  72. Im obliged for the post.Really thank you! Cool.

  73. us says:

    Thank you for your blog post.Really looking forward to read more.

  74. twitter says:

    Im obliged for the blog.Much thanks again. Will read on

  75. WOW emphatically what I was looking representing. Came here by thorough on behalf of other

  76. Thanks again for the blog.Really looking forward to read more. Much obliged.

  77. There is definately a lot to find out about this subject. I love all the points you ave made.

  78. Usually I do not learn article on blogs, however I wish to say that this write-up very pressured me to take a look at and do it! Your writing taste has been surprised me. Thanks, very great article.

  79. website says:

    Thank you for your blog article. Really Cool.

  80. If you are concerned to learn Web optimization techniques then you should read this article, I am sure you will obtain much more from this article concerning SEO.

  81. Looking around I like to look around the web, regularly I will just go to Stumble Upon and follow thru

  82. good day says:

    Simply a smiling visitor here to share the love (:, btw outstanding pattern. Make the most of your regrets. To regret deeply is to live afresh. by Henry David Thoreau.

  83. Horacio says:

    Its not my first time to pay a quick visit this web page, i am visiting this site dailly and get good facts from here every day.

  84. You made some clear points there. I looked on the internet for the topic and found most individuals will agree with your website.

  85. Neomi says:

    Muchos Gracias for your article post.Really thank you! Really Cool.

  86. Some really interesting info , well written and generally user genial.

  87. click here says:

    Thank you for your article.Much thanks again. Awesome.

  88. me suba says:

    lGeKxJ It as not that I want to replicate your internet site, but I really like the layout. Could you let me know which design are you using? Or was it tailor made?

  89. I truly appreciate this article.Really looking forward to read more. Keep writing.

  90. suba me says:

    yR1Uxt This blog is obviously cool additionally informative. I have chosen a bunch of useful stuff out of this blog. I ad love to return every once in a while. Thanks a lot!

  91. I was curious if you ever thought of changing the page layout of your website?
    Its very well written; I love what youve got to say. But maybe you could a little
    more in the way of content so people could connect with it better.

    Youve got an awful lot of text for only having 1 or
    2 images. Maybe you could space it out better?

  92. Merely wanna comment that you have a very nice web site , I love the design and style it actually stands out.

  93. Tania says:

    Some truly fantastic information, Gladiolus I discovered this.

  94. bistro masa says:

    Very good information. Lucky me I discovered your blog by chance (stumbleupon). I have bookmarked it for later!

  95. The topic is pretty complicated for a beginner!

  96. Wohh precisely what I was looking for, thanks for putting up.

  97. I’а†ve recently started a site, the information you offer on this web site has helped me greatly. Thank you for all of your time & work.

  98. casino says:

    Major thankies for the article post.Really looking forward to read more. Awesome.

  99. tractr says:

    Hello to every one, it’s actually a nice for me to pay a visit
    this web site, it includes priceless Information.

  100. You’re so awesome! I do not suppose I have read through anything like this before.
    So wonderful to find another person with some genuine thoughts on this subject.

    Seriously.. many thanks for starting this up. This web site is one thing that’s needed on fucked in the ass web, someone with a little originality!

  101. Excellent blog you have here.. It’s difficult to find high-quality writing like yours these days.
    I honestly appreciate people like you! Take care!!

  102. I am in fact grateful to the owner of this website who has shared this enormous post at here.

  103. This is a beautiful shot with very good lighting

  104. After I initially commented I appear to have clicked the
    -Notify me when new comments are added- checkbox and now every time a comment is added I recieve four emails with the same comment.
    Perhaps there is a way you are able to remove me from that service?
    Thanks!

  105. Often have Great blog right here! after reading, i decide to buy a sleeping bag ASAP

  106. This is getting a bit more subjective, but I much prefer the Zune Marketplace.

  107. Wow, great blog article.Much thanks again. Much obliged.

  108. This particular blog is without a doubt awesome and also diverting. I have chosen many useful stuff out of this amazing blog. I ad love to return again and again. Thanks!

  109. pretty valuable material, overall I think this is worth a bookmark, thanks

  110. Very good post! We will be linking to this particularly great article on our site. Keep up the good writing.

  111. luxury homes says:

    This is one awesome blog.Really looking forward to read more. Will read on…

  112. What’s Taking place i’m new to this, I stumbled upon this I’ve discovered It absolutely useful and it has helped me out loads.

    I’m hoping to contribute & aid different customers like its aided me.
    Great job.

  113. ghana News says:

    Very informative blog post.Thanks Again. Awesome.

  114. Thanks for sharing your info. I really appreciate your efforts and I will be waiting for your further post thanks once again.

  115. Very neat blog post.Thanks Again. Much obliged.

  116. Wow, great blog article.Really looking forward to read more. Keep writing.

  117. 먹튀검증 says:

    to me. Regardless, I am certainly pleased I discovered it and I all be book-marking it

  118. Mlb Picks says:

    That will be the end of this article. Here you

  119. Major thanks for the article post. Want more.

  120. m88 says:

    Genuinely when someone doesn’t understand afterward its up to other users that they will help, so here it takes place.

  121. You made some clear points there. I looked on the internet for the topic and found most guys will approve with your website.

  122. Good answers in return of this difficulty with firm arguments
    and describing the whole thing about that.

  123. Remarkable! Its in fact remarkable piece of writing,
    I have got much clear idea about from this article.

  124. Your style is so unique in comparison to other folks I’ve read stuff from.
    Thank you for posting when you’ve got the opportunity,
    Guess I will just bookmark this site.

  125. When some one searches for his necessary thing, thus he/she wants to be available that in detail, so that thing is maintained over here.

  126. JasaHoki88 says:

    Asking questions are really good thing if you are not
    understanding something entirely, except this piece of writing gives nice
    understanding yet.

  127. homo films says:

    Thanks so much for the post.Really thank you! Awesome.

  128. Loretta says:

    This excellent website definitely has all the information and facts I needed concerning this subject and didn at know who to ask.

  129. AwDEbi Keep up the great work , I read few articles on this site and I believe that your web site is really interesting and contains lots of superb information.

  130. Indo Bola365 says:

    If some one needs expert view about running a blog after that i suggest him/her to pay a
    quick visit this website, Keep up the nice work.

  131. I value the blog post.Thanks Again. Much obliged.

  132. There is definately a great deal to know about this subject. I love all of the points you ave made.

  133. 1Z0-337 exam says:

    Im no professional, but I believe you just crafted the best point. You clearly comprehend what youre talking about, and I can actually get behind that. Thanks for staying so upfront and so sincere.

  134. chocopie says:

    2YUM8B Nice answers in return of this issue with firm

  135. Quickly and easily build your web traffic and PR, which provides Web site visitors to add your page to any social bookmarking website.

  136. opalivf says:

    It’а†s really a cool and useful piece of info. I’а†m happy that you shared this helpful info with us. Please stay us informed like this. Thanks for sharing.

  137. You are my inhalation , I own few blogs and rarely run out from to brand.

  138. Excellent way of telling, and nice paragraph to obtain information concerning my presentation subject matter, which i am going to present in academy.

  139. venue finder says:

    This is a good tip especially to those new to the blogosphere. Brief but very precise information Appreciate your sharing this one. A must read post!

  140. Banh cuon — a popular dish tried on street food tours.

  141. Whats up! I simply wish to give a huge thumbs up for the nice information you may have here on this post. I will be coming back to your blog for extra soon.

  142. Just wanna state that this is very beneficial , Thanks for taking your time to write this.

  143. livefootball says:

    Amazing issues here. I am very happy to look your article.

    Thank you so much and I am having a look forward to contact you.
    Will you kindly drop me a e-mail?

  144. to start my own blog in the near future. Anyway, if you have any suggestions or techniques for new blog owners please

  145. I was curious if you ever thought of changing the page layout of

  146. produce a good article but what can I say I procrastinate a whole

  147. click here says:

    This dual-Air Jordan XI Low Bred is expected to make a

  148. Tattoo Shop says:

    Your style is very unique in comparison to other folks I ave read stuff from. Thank you for posting when you have the opportunity, Guess I all just book mark this site.

  149. tsx says:

    It as not that I want to copy your web site, but I really like the pattern. Could you tell me which style are you using? Or was it especially designed?

  150. This is a great tip particularly to those new to the
    blogosphere. Short but very precise info… Many thanks for sharing this one.
    A must read article!

  151. Good Cameras says:

    This paragraph will assist the internet visitors for building up new website or even a
    blog from start to end.

  152. When Someone googles something that relates to one of my wordpress blogs how can I get it to appear on the first page of their serach results?? Thanks!.

  153. xznssdoi,Are you searching for top class Escort service in Noida and want to enjoy with them, hire sexy girls from top Greater Noida escort service and enjoy full nightI LOve your Blog!.

  154. I think that may be an interesting element, it made me assume a bit. Thanks for sparking my considering cap. On occasion I get so much in a rut that I simply really feel like a record.

  155. SolarMovies says:

    How about we return to my live show. It is so cool and as of recently I can’t overlook my inclination about it. Do you regularly to go live shows? What sort of music do you like tuning in to? Who is your preferred artist?

  156. healthe care says:

    general physician doctor works by break blood vessels in the body to flourish blood transmission to the penis during sex stimulation. As the arteries in the penis go into to freeze and stretch, blood gurgle gone of the penis is restricted, ergo causing an erection with cheap viagra paypal.

  157. Really appreciate you sharing this article post.Thanks Again. Really Cool.

  158. brcko says:

    wow, awesome blog article.Really thank you! Want more.

  159. waec says:

    Major thanks for the blog.Really looking forward to read more. Want more.

  160. It as not that I want to duplicate your web page, but I really like the design and style. Could you let me know which theme are you using? Or was it custom made?

  161. Just a smiling visitant here to share the love (:, btw outstanding style.

  162. wow, awesome blog post.Really looking forward to read more. Cool.

Leave a Reply to Share Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>