0

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.

Screenshot

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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.