Question

I have a JMX enabled application which creates RMI Registry by doing:

rmiRegistry = LocateRegistry.createRegistry(registryPort);

and then later on it creates JMXConnectorServer by doing:

JMXServiceURL url = new JMXServiceURL(
      "service:jmx:rmi://localhost:" + serverPort 
      + "/jndi/rmi://:" + registryPort + "/jmxrmi");

connector = JMXConnectorServerFactory.newJMXConnectorServer(
                    url, 
                    null,
                    ManagementFactory.getPlatformMBeanServer());
connector.start();

My problem is that I cannot connect to this JMX Server from a remote host using JConsole. I've followed the instructions for debugging/tracing JConsole and I can see that the problem is that JConsole tries to connect to a bogus IP address that it must have gotten from the Registry. Ok, it isn't exactly bogus because it happens to correspond to a virtual network interface I have on the JMX Server host machine. How on earth does JMX pick that up?

A netstat on my application reveals that both the serverPort and the registryPort are bound on the wildcard interface (on both IP4 and IP6) which is as expected since I haven't supplied socket factories. Basic connectivity works from the remote host, i.e. I can get the telnet test to pass on both ports.

I would have assumed that I would have to change 'localhost' in the JMXServiceURL to the name of my host (as other hosts sees it, not how it sees itself) but that doesn't help.

What do do ?

UPDATE1

After some more investigation I'm pretty sure this 'bogus IP address' comes because RMI just picks the first IP it finds on its own host and then uses that as its 'call-me-back' address. It then happens to find that virtual NIC that exists on this host. That's really not want I want. I want to be able to control explicitly the RMI 'call-me-back' address.

Was it helpful?

Solution

Welcome to RMI hell.

The end point resolve himself and send back to jconsole the ip to use.

If you can try to use JMXMP : http://meteatamel.wordpress.com/2012/02/13/jmx-rmi-vs-jmxmp/.

You can also try java.rmi.server.hostname : http://docs.oracle.com/javase/7/docs/platform/rmi/spec/rmi-properties2.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top