tags:

views:

561

answers:

1

I've been going through several examples on how to add MBeans to JBoss 5.0 so they can be configured though the JMX Console, but none of these examples have ever shown up in the JMX view. I've now tried to get ehCache's JMX integration to work to no avail.

I'm trying (as in the ehCache documentation) the following:

CacheManager manager = CacheManager.create("./ehcache.xml");
MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer();
ManagementService.registerMBeans(manager, mBeanServer, false, false, false, true);

I never see any errors with my own or now with the ehCache version, but it never shows up in the JMX view. I'm wondering - is there a setting I need to make to to the JBoss configuration to get it to pick up these additions? Am I missing something fundamental? Any hints?

Thanks for any help. I'm pulling my hair out here.

A: 

If you're running JBoss on Java 5 or above, then you'll likely have 2 MBean servers running: the "platform" mbean server, which is hosted by the JVM, and the JBoss MBean server, which is hosted by the JBoss code. The two have nothing to do with each other.

Your posted code will register ehcache's mbean in the JVM platform server, which is no use to you.

The easiest way to get a programmatic reference to the JBoss MBean server is

org.jboss.mx.util.MBeanServerLocator.locateJBoss()

Try using that instead of

ManagementFactory.getPlatformMBeanServer();
skaffman
Would you be able to tell me which jar file the MBeanServerLocator is included in? Thanks!
Scratch that. I was able to hunt that down - it's in the jboss-j2se.jar file in JBoss 5.0