I have a web application running on JBoss 4.2.2. In order to monitor performance I have enabled the internal platform JMX server that ships with Java 5. In other words, I added:
-Dcom.sun.management.jmxremote
to JBoss' launch script. This works as expected. However, as a result of this, all MBeans are now registered on the platform MBeanServer. I don't want that, I want them to be registered on JBoss' MBeanServer.
The difficulty lies in the fact that I use Spring to register my managed beans. For this, MBeanExporter is used. Thus, I need to tell my MBeanExporter to use JBoss' MBeanServer when registering beans. However, the only exposed method in MBeanExporter to affect what server is used is setServer(MBeanServer mBeanServer). The problem is that I only know how to get a reference to the correct MBeanServer programmatically, and not in Spring's XML, where the MBeanExporter is declared.
My options appears to be:
- Write a subclass to
MBeanExporter, overriding certain methods, so the correct MBeanServer is loaded - Write a
PostBeanProcessorthat finds JBoss' MBeanServer and then callssetServer - JNDI? Only works if the MBeanServer is exposed in JNDI, and I haven't been able to find it.
What is the most idiomatic way? Am I doing something really silly?