linkage error: javax/management/MBeanServerConnection
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Tuesday, April 20, 2010 08:30 AM

JMXServiceURL address = new JMXServiceURL( "service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi"); JMXConnector connector = JMXConnectorFactory.connect(address); MBeanServerConnection mbs = connector.getMBeanServerConnection(); ObjectName oname = new ObjectName( ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME); // Memory Usage factors if (mbs.isInstanceOf(oname,"com.sun.management.OperatingSystemMXBean")) { // Get platform-specific attribute "ProcessCpuTime" long cpuTime = (Long) mbs.getAttribute(oname, "ProcessCpuTime"); System.out.println("process cpu time " + cpuTime); } what is wron   More>>


JMXServiceURL address = new JMXServiceURL(
"service:jmx:rmi:///jndi/rmi://localhost:3000/jmxrmi");

JMXConnector connector = JMXConnectorFactory.connect(address);
MBeanServerConnection mbs = connector.getMBeanServerConnection();




ObjectName oname = new ObjectName(
ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);

// Memory Usage factors
if (mbs.isInstanceOf(oname,"com.sun.management.OperatingSystemMXBean")) {
// Get platform-specific attribute "ProcessCpuTime"
long cpuTime = (Long) mbs.getAttribute(oname, "ProcessCpuTime");
System.out.println("process cpu time " + cpuTime);
}

what is wrong with this connection????

   <<Less

Re: linkage error: javax/management/MBeanServerConnection

Posted By:   Anonymous  
Posted On:   Monday, May 3, 2010 01:46 AM

Hi Deb,

Even i am looking for the same. I need to fetch the
information for the CPU utilization of a JVM running on that system.For that i got
"com.sun.management.OperatingSystemMXBean", which provides
CPU time used by the process on which the Java virtual machine
is running NOT the '%CPU Usage' time which i was hoping to get.


Well, in your case i feel problem is here--

ObjectName oname = new ObjectName( ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME);

This will never give you the instance of com.sun.management.OperatingSystemMXBean.

Correct me if i am wrong?
About | Sitemap | Contact