Our JBoss server.xml file has this line:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="app_server_01">
Is there any way to get the jvmroute value (in this case app_server_01) at runtime using Java?
Background
We’ve got session affinity (sticky sessions) configured between our app servers and Apache servers. JBoss appends the jvmroute (app_server_01) to the JSESSIONID. We have multiple apps configured on a single host, but running on different app servers. We want to append the appropriate jvmroute to the JSESSIONID using a servlet filter.
JMX version
You can query the Engine’s MBean to get this information:
XML Parsing version
Another option is to use the “jboss.server.home.dir” system property to find the full path of the server.xml file, and then just open it using an XML parser.
For example, in JBoss 4.2.2, the server.xml file is at:
You can load this file into whatever XML parser you like.
In JBoss 5.1.0, the directory structure has changed, so it would be: