简体   繁体   中英

MBean “jboss.web:type=Manager,path=/,host=localhost” not found

I'm trying to access the JBoss v4.2 MBean registered as

jboss.web:type=Manager,path=/,host=localhost

using the following code:

ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
ManagementFactory.getPlatformMBeanServer().getAttribute(name, "activeSessions");

But this code keeps throwing the following exception:

javax.management.InstanceNotFoundException : jboss.web:type=Manager,path=/,host=localhost is not registered.

On the other hand I'm able to see and use this bean using the jmx-console via ...//localhost:8080/jmx-console/ - the MBean is available.

屏幕截图

What else is necessary to access the same MBean via code?

Found it...

ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
this.sessions = new Long((Integer) MBeanServerLocator.locateJBoss().getAttribute(name, "activeSessions"));

I had to find the right MBeanServer... MBeanServerLocator.locateJBoss() solves it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM