Glassfish v2.1.1 Cluster Session Replication inconsistent behavior

Everytime I take up a task on adding Cluster Support to my j2ee application, the whole experience gets quite exciting with new kinds of challenges 🙂

In the past, it was with Weblogic, Websphere etc…and this time it was Glassfish 🙂
Ok, like many of you, I managed to setup the cluster environment in glassfish and deployed “ClusterJsp” application to check out Session Failover, Load balancing etc…
What I found was that, if I keep refreshing the ClusterJsp page 5 to 10 times, my Session Id keeps changing…going to say that Glassfish lost my session somewhere in between these requests.
After googling and bing’ing a lots, I managed to find this link, which explained the issue in detail.
Basically, we should add the following snippet in sun-web.xml
After adding the above entry, Glassfish started behaving as expected.
Now what I donot quite understand is, why was this behavior not made a default behavior !!!
I am sure there is a good reason for it, will update If I get to know.

3 thoughts on “Glassfish v2.1.1 Cluster Session Replication inconsistent behavior

  1. Hey, we're seeing a similar problem with multiple session id's, but I'm wondering, were you using sticky sessions in your load balancer? Seems based on that link that the problem might not happen if all requests for a user were routed to the same Glassfish instance.

    Like

  2. Yes, We do use sticky sessions in our load balancer. However since, am not sure about the exact cause for the session info being lost in Glassfish, I was worried as to what if this behavior happens even If my requests go to the same server due to stick sessions. Hence to be safe, I added these entries in sun-web.xml.

    Like

  3. This has solved a problem I've been having for a long time! Just for info: I'm using Glassfish Open Source 3.1.1, with an Apache 2.2 front-end using mod_jk. I had problems with my sessions being lost, and new ones created – not what I wanted when performing a failover. I then added the property specified to the “glassfish-web.xml” and everything works peachy!

    Thanks again Karthik!

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s