InstanceNotFoundException: java.lang:type=Runtime
I am puzzled by this behavior of my Mbean Object. It displays all stats on one server, and on the other one, throws the InstanceNotFoundException: java.lang:type=Runtime... Both servers are running the same version and set up for everything...
This is the code snippet:
java.lang.Long upTime = new Long(0);
try {
ArrayList servers = MBeanServerFactory.findMBeanServer(null);
if (servers == null)
throw new Exception("No MBeanServer found.");
MBeanServer server = (MBeanServer)servers.get(0);
ObjectName javaRuntime = new ObjectName("java.lang:type=Runtime");
//Error thrown by the line below:
upTime = (java.lang.Long) server.getAttribute(javaRuntime, "Uptime");
} catch (Exception e) {
e.printStackTrace();
}
Could someone please guide me to the mistake here?
Your help is greatly appreciated!
The exact exception thrown is:
javax.management.InstanceNotFoundException: java.lang:type=Runtime
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(Defaul
tMBeanServerInterceptor.java:1010)
at com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getAttribute(De
faultMBeanServerInterceptor.java:627)
at com.sun.jmx.mbeanserver.JmxMBeanServer.getAttribute(JmxMBeanServer.ja
va:659)
at com.hns.rpms.mib.k_rpmsConfig.k_get(k_rpmsConfig.java:230)
at com.hns.rpms.mib.v_rpmsConfig.v_get(v_rpmsConfig.java:209)
at com.snmp.agent.lib.SRSNMPAgent.handleGetRequestEvent(SRSNMPAgent.java
:1219)
at com.snmp.agent.lib.SRSNMPAgent.access$900(SRSNMPAgent.java:59)
at com.snmp.agent.lib.SRSNMPAgent$SAMLThread.run(SRSNMPAgent.java:1879)

