Can't connect to JConsole of JDK6

Hi everyone,

I have a JMX-enabled web application running on a JBoss-4.0.2. I've created my own MBeanServer and an RMIConnector.

When i connect with JConsole from JDK 5 or other management console (JManage, MC4J,...) there is no problem. When I use JConsole of JDK6 on the other hand, then I can't retrieve my MBeans. I do connect but I get MBeans of JMImplementation and java.lang but not those I've created.

Can anyone help me with this problem.

Thx,

Robin Merckx

[505 byte] By [RobinMa] at [2007-10-3 11:58:42]
# 1

Hi Robin,

I'm afraid the problem you encounter is because you are trying to connect to your JMX agent by selecting it in the Local Process table. You should know that in such a case the out-of-the-box management agent will be started, if not already running, and JConsole will connect to it. This means same JMX agent but a different RMIConnectorServer and a different MBeanServer.

In order to connect to your RMIConnectorServer and MBeanServer supply the JMXServiceURL in the Remote Process section.

In fact, you may want to add your custom MBeans to the platform MBean server instead of creating a new one.

java.lang.management.ManagementFactory.getPlatformMBeanServer();

Regards,

Luis-Miguel Alventosa

Java SE - JMX - JConsole development team

Sun Microsystems, Inc.

lmalventa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 2
i am using the JMXServiceURL on the remote process to connect to my MBeanServer. I also added my MBeans to the platform MBeanServer but with the same result.Do i have to compile my code with JDK6 to make JConsole from JDK6 able to connect to the MBean server?Robin
RobinMa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 3

Hi Robin,

I'm a bit confused here. If you've created your own MBeanServer, added your custom MBeans to it and created an RMIConnectorServer with that MBeanServer then you should see your MBeans independently of the JConsole version you are using when you supply the JMXServiceURL of the form "service:jmx:rmi:///jndi/rmi://host:port/my-server-name" to JConsole. No you don't need to compile your code with JDK 6.

Could you please tell me whtat your JMXServiceURL looks like?

Regards,

Luis

lmalventa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 4

Hi Luis,

You're not the only one who is confused.

service:jmx:rmi://localhost/jndi/rmi://localhost:9589/jmx

This is the JMXServiceURL that i use. As said befor, it works fine with all management consoles I tested exept JConsole JDK6

here is a snippet of my code where I create the RMIConnectorService

MBeanServer server = ManagementFactory.getPlatformMBeanServer();

LocateRegistry.createRegistry(9589);

String userFile = Path.getInstance().getPath()+"/WEB-INF/jmxusers.txt";

Map<String, String> env = new HashMap<String, String>();

env.put("jmx.remote.x.password.file", userFile);

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();

RobinMa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 5
Hi Robin, Do you register your MBeans in the platform MBeanServer as well?regards,-- danielJMX, SNMP, Java, etc... http://blogs.sun.com/jmxetc
dfuchsa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 6

Hi Daniel,

Normally I create my own MBeanServer but I抳e changed it to the platform MBeanServer like Luis suggested

MBeanServer server = ManagementFactory.getPlatformMBeanServer();

used to be

MBeanServer server = MBeanServerFactory.createMBeanServer("JMXserver");

but they both fail to let me see my MBeans in Jconsole JDK6

Robin

RobinMa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 7

Hi Robin,

I'm having the same problem you encountered.

I've recently switched using JConsole 6 as JMX Client (because JConsole 5 doesn't show attribute info as a tooltip).

Everything works fine using JConsole 5, AdventNet or XtremeJ. But with JConsole 6 I don't see my MBeans, I get connected though seeing the same things you do.

Did you find out what was wrong?

Thanks,

Erik

Erik_Va at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 8

Hi Erik and Robin,

The way JConsole JDK 6 behaves looks very strange and it looks like

you were connecting to two different MBeanServers when connecting

with JConsole JDK 5 and JConsole JDK 6.

Could you please do the following test:

<ul>

<li>Run JConsole JDK 5</li>

<li>Connect to JMX agent by entering the following JMXServiceURL <b>service:jmx:rmi:///jndi/rmi://<host>:<port>/<server-name></b> in the Advanced tab in the Connection Dialog</li>

<li>Go to the MBeans tab and write down the MBeanServerId attribute in the MBeanServerDelegate MBean under the JMImplementation tree node</li>

</ul>

<ul>

<li>Run JConsole JDK 6</li>

<li>Connect to JMX agent by entering the following JMXServiceURL <b>service:jmx:rmi:///jndi/rmi://<host>:<port>/<server-name></b> in the Remote Process field in the Connection Dialog</li>

<li>Go to the MBeans tab and write down the MBeanServerId attribute in the MBeanServerDelegate MBean under the JMImplementation tree node</li>

</ul>

Then compare the two MBeanServerIds and check if they are the same and let me know.

Thanks in advance,

Luis

lmalventa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...
# 9

It appears there is indeed a bug in JConsole when connecting to URLs of the form

service:jmx:rmi://localhost/jndi/rmi://localhost:1234/foo

You can work around it by instead using the (supposedly) equivalent URL

service:jmx:rmi:///jndi/rmi://localhost:1234/foo

In other words, just delete the first "localhost".

This bug is being tracked as bug 6538179 <http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6538179>.

Thanks to Robin and Erik for their help in pinpointing the problem.

蒩monn McManus -- JMX Spec Lead -- http://weblogs.java.net/blog/emcmanus

emcmanusa at 2007-7-15 14:34:40 > top of Java-index,Core,Monitoring & Management...