Bug 56096 - Setting rmiBindAddress on JmxRemoteLifecycleListener prevents tomcat from starting
Summary: Setting rmiBindAddress on JmxRemoteLifecycleListener prevents tomcat from sta...
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 7.0.50
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2014-01-31 20:59 UTC by Jim Talbut
Modified: 2014-12-19 19:16 UTC (History)
1 user (show)


Note You need to log in before you can comment on or make changes to this bug.
Description Jim Talbut 2014-01-31 20:59:36 UTC
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.
Comment 1 Jim Talbut 2014-01-31 21:00:21 UTC
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,

@@ -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("/jndi/rmi://localhost:");
+        url.append("/jndi/rmi://");
+        url.append(bindAddress);
+        url.append(":");
         JMXServiceURL serviceUrl;
Comment 2 Violeta Georgieva 2014-02-04 18:56:38 UTC
Thanks for the report.
Fixed in trunk and 7.0.x and will be included in 8.0.2 and 7.0.51 onwards.