United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6538179 REGRESSION: JConsole connects to wrong MBean Server with URL service:jmx:rmi://localhost/jndi/...
JDK-6538179 : REGRESSION: JConsole connects to wrong MBean Server with URL service:jmx:rmi://localhost/jndi/...

Details
Type:
Bug
Submit Date:
2007-03-23
Status:
Resolved
Updated Date:
2010-07-29
Project Name:
JDK
Resolved Date:
2007-04-07
Component:
tools
OS:
generic
Sub-Component:
jconsole
CPU:
generic
Priority:
P3
Resolution:
Fixed
Affected Versions:
6
Fixed Versions:
6u2 (b02)

Related Reports
Backport:

Sub Tasks

Description
Create an RMI server using code like the following:
        MBeanServer server = ManagementFactory.getPlatformMBeanServer();
        LocateRegistry.createRegistry(9589);
        JMXServiceURL addr = new JMXServiceURL("rmi", null, 0, "/jndi/rmi://localhost:9589/jmx");
        RMIConnectorServer cs = new RMIConnectorServer(addr, env);
        ObjectName name = new ObjectName("connector:type=cserver,name=mycserver");
        server.registerMBean(cs, name);
        cs.start();

Then run jconsole using a URL like this:
    jconsole service:jmx:rmi://localhost/jndi/rmi://localhost:9589/jmx

The MBean Server you see is not the one created above.

This is a regression, because JConsole from JDK 5.0 does the right thing.  The bug is in JConsole, because if you create a connection programmatically using the same URL it works correctly.

This problem was reported on the SDN JMX forum by Robin Merckx and Erik Vaneylen; see <http://forum.java.sun.com/thread.jspa?messageID=9569129>.

                                    

Comments
WORK AROUND

The first occurrence of "localhost" in a URL of this form is supposed to be ignored, so you can omit it.  In other words, you can do
    jconsole service:jmx:rmi:///jndi/rmi://localhost:9589/jmx
instead of
    jconsole service:jmx:rmi://localhost/jndi/rmi://localhost:9589/jmx
and it works correctly.
                                     
2007-03-23
EVALUATION

JConsole wrongly auto-connects to itself as if "localhost:0" had been entered
in the Remote Process field when the entered JMXServiceURL is of the form:

    service:jmx:rmi://localhost/jndi/rmi://<host>:<port>/<server-name>
                                     
2007-03-23
SUGGESTED FIX

------- ProxyClient.java -------
319c319
<         if (hostName != null && hostName.equals("localhost") && port == 0) {
---
>         if (jmxUrl == null && hostName != null && hostName.equals("localhost") && port == 0) {
                                     
2007-03-24



Hardware and Software, Engineered to Work Together