JMX cannot get OperatingSystem info

I have a server process that I want to monitor in a web page. I would like to display some Operating System information on the web page for my server. I can view the information from my server in jconsole, but I cannot figure out how to get some of the same information in the web page. When I run the code:

JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");

JMXConnector jmxc = JMXConnectorFactory.connect(url, null);

ObjectName objName = new ObjectName( "java.lang:type=OperatingSystem" );

MBeanServerConnection serverConnection = conn.getMBeanServerConnection();

ObjectInstance instance = serverConnection.getObjectInstance( objName );

I get an exception:

javax.management.InstanceNotFoundException: java.lang:type=OperatingSystem

Where am I going wrong?

[855 byte] By [ElihuSmailsa] at [2007-10-3 11:09:44]
# 1
> MBeanServerConnection serverConnection => conn.getMBeanServerConnection();Is 'conn' a type mistake or what? You should you the JMXConnector you declared above.
michele81a at 2007-7-15 13:32:49 > top of Java-index,Core,Monitoring & Management...
# 2

I'm afraid the JMXConnectorServer you're trying to connect to is not using the platform MBean server where the JVM MXBeans are registered.

In order to get the platform MBean server you can call:

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

Then pass it in to your JMXConnectorServer at construction time.

Regards,

Luis

lmalventa at 2007-7-15 13:32:49 > top of Java-index,Core,Monitoring & Management...