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