views:

2071

answers:

4

I have a requirement of having to run multiple tomcat server in single physical box. While accessing these from a browser, when user switches between the applications, it results in logging out the user previously access application. This is because of JSESSIONID cookie conflict.

One possible solution is to run each applications in different context. Unfortunately, my applications will not work in context path setting as none of the resources are accessed with request.getContextPath() prepended in front.

This leaves me to change the name of cookie JSESSIONID to resolve the conflict. Is there a way to do this? If yes, how?

Hope I'm clear in stating my question.

Note: All my application are running in different port in the same machine.

+3  A: 

I don't think it's possible at this point - see https://issues.apache.org/bugzilla/show_bug.cgi?id=42419

The last entry states "This has been fixed in 5.5.x and will be included in 5.5.28 onwards" - which is the next point release - 5.5.27 is the current release.

Martin
Thanks for digging this out. Looks like only option left for me is to modify the existing tomcat source. The bug/feature report clearly states my exact requirement and solution.Thanks for the answer.
ramanr
+1  A: 

Not 100% sure if this will work, but you can use the jvmRoute attribute, which is generally used in a load-balanced/clustered environment for the load balancers to be able to tell the nodes apart. Example:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="node1">

This will end up generating a JSESSIONID value that looks like "ABCDEF123456.node1".

Documentation link.

matt b
A: 

No, not really. jvmRoute could only affect the JSESSIONID value by appending the route name with a period symbol. the cookie name was hardcoded. So possible solution shall add a mod_proxy to handle cookie name or modify the source code of tomcat.

iMax
+1  A: 

By Using two following system properties this can be achieved with ease.

  • org.apache.catalina.SESSION_COOKIE_NAME
  • org.apache.catalina.SESSION_PARAMETER_NAME

Any value can be passed to above properties to change the default values.

Here complete details with some sample script is found.