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

穿精又带淫゛_ 提交于 2019-12-13 07:13:48

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/15632000/mbean-jboss-webtype-manager-path-host-localhost-not-found

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!