Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JMX server locator replacement in JBoss AS 7 for class MBeanServerLocator

Tags:

jmx

jboss7.x

I am currently using JBoss 4.3 for a web application. I would like to move to the JBoss AS 7. I have been able to fix must of the differences of the application in both versions but one. The application has some JMX beans that are created thru the spring framework. Unfortunately the AS 7 release removed the class: org.jboss.mx.util.MBeanServerLocator which was used in spring to locate the JBoss JMX server and create some beans. I am not to familiar with JMX but so far the only thing I have found so far is: "http://lists.jboss.org/pipermail/jboss-as7-dev/2011-February/000569.html". I was wondering if somebody knows how to replace the class above from JBOSS with the new JMX 1.6 classes. Here is my spring configuration snipet for the piece I need to fix:

<bean class="org.springframework.jmx.export.MBeanExporter">
    <property name="server">
        <bean class="org.jboss.mx.util.MBeanServerLocator" factory-method="locateJBoss"/>
    </property>
      <property name="beans">
        <map>
          <entry key="MywebMbeans:name=profileListenerContainer" value-ref="profileListenerContainer"/>
          <entry key="MywebMbeans:name=jmsSenderService" value-ref="jmsSenderService"/>
          <entry key="MywebMbeans:name=mailSender" value-ref="mailSender"/>
        </map>
      </property>
      <property name="assembler" ref="mbeanAssembler"/>
</bean>

Thanks,

like image 681
ortizfabio Avatar asked Jul 21 '11 19:07

ortizfabio


1 Answers

The MBeanServer used by JBoss 7 (by default) is the platform MBeanServer. The class name is com.sun.jmx.mbeanserver.JmxMBeanServer and the default domain is DefaultDomain. Accordingly, you can simply use:

java.lang.management.ManagementFactory.getPlatformMBeanServer()

Alternatively:

    for(MBeanServer server: javax.management.MBeanServerFactory.findMBeanServer(null)) {
        if("DefaultDomain".equals(server.getDefaultDomain())) return server;
    }
    throw new Exception("Failed to locate MBeanServer");
like image 163
Nicholas Avatar answered Sep 27 '22 17:09

Nicholas