I have a similar setup using the same config for mod_cluster and and custom session id.
My solution worked with mod_cluster 1.2.0 and jBoss AS 7.1.0 but it is not working with jBoss AS 7.1.1.
It seems stickysession is no longer being honoured as I see a few calls being routed to the first node, then the next call to being routed to the second node.
Here is my mod_cluster config
Deny from all
Allow from 10.152
ServerAdvertise on http://@IP@:6666
ProxyPass / balancer://main-server-group/ stickysession=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse / balancer://main-server-group/ stickysession=JSESSIONID|jsessionid
Deny from all
Allow from 10.152
Config from jBoss
<mod-cluster-config advertise-socket="modcluster" proxy-list="10.152.20.223:6666" balancer="main-server-group" domain="main-server-group" advertise-security-key="ConnectAdSecurityKey" sticky-session="true" sticky-session-force="true">
<dynamic-load-provider history="10" decay="2">
<load-metric type="cpu" weight="2" capacity="100"/>
<load-metric type="sessions" weight="1" capacity="512"/>
I finally got sticky sessions to work, but the solution was not pretty
The servlet spec does allow custom session cookies to be used, and in Catalina Engine, you do that by
setting the system property org.apache.catalina.SESSION_COOKIE_NAME and org.apache.catalina.SESSION_PARAMETER_NAME
Initially, I tried to simply set these properties in standalone-ha.xml (basically as a <system-properties> tag)
However, it did not seem to matter.
Finally, I got the source cod eof mod_cluster, and went into DefaultMCMPRequestFactory and added logging to it
I notice that the following lines return the session cookie name and parameter to be JSESSIONID,jsessionid
String sessionCookieName = engine.getSessionCookieName();
String sessionParameterName = engine.getSessionParameterName();
Irrespective of the system property that is being set. It looks like whatever engine is being used was hardcoding
the session cookie name and parameter.
I patched this class to override engine.getSessionCookieName(), with a system property if it found org.apache.catalina.SESSION_COOKIE_NAME
and with this patch, sticky sessions work.
I still need to investigate why the engine hardcodes jsessionid....
cursorily looking at mod_cluster source code, it appears to me CatalinaEngine is the only thing hardcoding this , but when i changed it to accept Globals.SESSION_COOKIE_NAME
and Globals.SESSION_PARAMETER_NAME,, it did not seem to make a difference.
Just checked out jboss as7 source code as well, and realized that the Globals.java class has been modified. The session cookie system property is not
org.apache.catalina.SESSION_COOKIE_NAME, but org.apache.catalina.JSESSIONID...
when you set this property in standalone.xml sticky sessions will work
This is my code for setting the cookie as my sessionIds are coming from an upstream system.
ResponseBuilder responseBuilder = Response.status(status);
sessionId = sessionId + "." + java.net.InetAddress.getLocalHost().getHostName();
NewCookie sessionCookie = new NewCookie("JSESSIONID", sessionId, request.getContextPath(), null, 1, null, 600, false);
This solution worked with jBoss7.1.0 but not when I moved to jBoss 7.1.1