Adding this Listener to the Server: <Listener className="org.apache.catalina.mbeans.JmxRemoteLifecycleListener" rmiRegistryPortPlatform="10001" rmiServerPortPlatform="10002" rmiBindAddress="${ip.address}" /> Along with this setenv.sh: CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.password.file=$CATALINA_HOME/conf/jmxremote.password" CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.access.file=$CATALINA_HOME/conf/jmxremote.access" CATALINA_OPTS="${CATALINA_OPTS} -Dcom.sun.management.jmxremote.ssl=false" Prevents tomcat from starting as the two RMI components cannot talk to each other, producing this error: java.io.IOException: Cannot bind to URL [rmi://localhost:10001/jmxrmi]: javax.naming.ServiceUnavailableException [Root exception is java.rmi.ConnectException: Connection refused to host: localhost; nested exception is: This is caused by the preparation of the URL in createServer, which doesn't take into account that rmiBindAddress has been used and useLocalPorts has not. I believe that if useLocalPorts was used tomcat would start, but this would force different instances to use different ports, which is what I'm trying to avoid.
Diff of a fix that works for me: Index: java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java =================================================================== --- java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (revision 1563195) +++ java/org/apache/catalina/mbeans/JmxRemoteLifecycleListener.java (working copy) @@ -255,7 +255,7 @@ // Create the Platform server - csPlatform = createServer("Platform", rmiRegistryPortPlatform, + csPlatform = createServer("Platform", rmiBindAddress, rmiRegistryPortPlatform, rmiServerPortPlatform, env, csf, ssf, ManagementFactory.getPlatformMBeanServer()); @@ -264,7 +264,7 @@ } } - private JMXConnectorServer createServer(String serverName, + private JMXConnectorServer createServer(String serverName, String bindAddress, int theRmiRegistryPort, int theRmiServerPort, HashMap<String,Object> theEnv, RMIClientSocketFactory csf, RMIServerSocketFactory ssf, MBeanServer theMBeanServer) { @@ -278,12 +278,20 @@ serverName, Integer.toString(theRmiRegistryPort)), e); return null; } + + if (bindAddress == null) { + bindAddress = "localhost"; + } // Build the connection string with fixed ports StringBuilder url = new StringBuilder(); - url.append("service:jmx:rmi://localhost:"); + url.append("service:jmx:rmi://"); + url.append(bindAddress); + url.append(":"); url.append(theRmiServerPort); - url.append("/jndi/rmi://localhost:"); + url.append("/jndi/rmi://"); + url.append(bindAddress); + url.append(":"); url.append(theRmiRegistryPort); url.append("/jmxrmi"); JMXServiceURL serviceUrl;
Thanks for the report. Fixed in trunk and 7.0.x and will be included in 8.0.2 and 7.0.51 onwards. Regards Violeta