I was using ManagementFactory to get ManagedMbeans in JDK1.5 and JBOSS 4.X. Now wanted to move my same code to JDK 1.6. The Mbean part breaks throwing the exception
Caused by: javax.management.NotCompliantMBeanException: Class does not expose a management interface: java.lang.Object Caused by: java.lang.Exception: Unable to register platform (JVM) MBeans with JBoss MBeanServer
Here's 2 approaches:
Sample Code For #2
This is a JBoss ServiceMBean implementation that will cross publish platform agent MXBeans to the JBoss MBeanServer. (Imports removed for brevity). It is a slightly different approach to the one I outlined, but spiritually, it is the same. There's a couple of extra hoo-has in there to manage the forwarding of notifications.
The interface is trivial
This MBean deployment descriptor will deploy the service: