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
  • 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"

      <insert path="/:web-app/:filter[1]" position="before">

      <insert path="/:web-app/:filter-mapping[1]" position="before">

      <insert path="/:web-app/:listener" position="before">


  • 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 ( and place it in the tomcat/shared/classes directory.
# the group name, password and port configured in the custom-slingshot-application-context.xml = slingshot = 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 -->

<!-- There is a bug in ClientConfigBuilder that's fixed in 2.4.1 -->

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.

47 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.

Leave a Reply to free apk download for windows pc 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>