我正在尝试访问注册为
的 JBoss v4.2 MBeanjboss.web:type=Manager,path=/,host=localhost
使用以下代码:
ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
ManagementFactory.getPlatformMBeanServer().getAttribute(name, "activeSessions");
但是这段代码不断抛出以下异常:
javax.management.InstanceNotFoundException : jboss.web:type=Manager,path=/,host=localhost is not registered.
另一方面,我可以使用jmx-console通过... // localhost:8080 / jmx-console /来查看和使用这个bean。 - MBean可用。
通过代码访问同一MBean还需要什么?
答案 0 :(得分:1)
发现它......
ObjectName name = new ObjectName("jboss.web:type=Manager,path=/,host=localhost");
this.sessions = new Long((Integer) MBeanServerLocator.locateJBoss().getAttribute(name, "activeSessions"));
我必须找到合适的MBeanServer ...... MBeanServerLocator.locateJBoss()
解决它。