0

I currently export my JMX beans using Spring and am quite happy with it. When running on another container ( e.g. Jetty, Tomcat ) I can simply connect using JConsole or JVisualVM and access my MBeans.

I have tried connecting to WebSphere using the instructions from How do you enable JMX in WebSphere with no success.

Is there a simpler way of accessing JMX beans on an application running on WebSphere Application Server 7.0 ?

Community
  • 1
  • 1
Robert Munteanu
  • 67,031
  • 36
  • 206
  • 278

1 Answers1

1

Not sure if you cannot connect to WebSphere7 JMX, or you can connect but do not see your exported MBeans. If it is the latter, I suspect you may be looking at the wrong MBeanServer instance, since WAS technically has more than one running.

Either way, to bypass all that nonsense, your best bet is to add a JMXConnectorServer definition in your Spring XML. That way, you control exactly how the JMX connections should be made, and it will use the standard J2SE RMI remoting, so you know your JConsole will connect to it easily.

Here's an example:

<bean id="MBeanServer"
    class="org.helios.jmx.util.MBeanServerFactory" lazy-init="false" factory-method="createMBeanServer">
    <constructor-arg type="java.lang.String" value="DefaultDomain" />
</bean>

<bean id="MBeanServerJMXUrl"
    class="javax.management.remote.JMXServiceURL" lazy-init="false">
    <constructor-arg type="java.lang.String" value="service:jmx:rmi:///jndi/rmi://localhost:8003/jmxrmi" />
</bean>

<bean id="RMIRegistry"
    class="java.rmi.registry.LocateRegistry" 
        lazy-init="false" 
        factory-method="createRegistry">
    <constructor-arg value="8003" />
</bean>


<bean id="MBeanServerConnector"
    class="javax.management.remote.JMXConnectorServerFactory" 
        lazy-init="false" 
        init-method="start"
        factory-method="newJMXConnectorServer"
        depends-on="RMIRegistry">
    <constructor-arg ref="MBeanServerJMXUrl" />
    <constructor-arg>
        <map/>
    </constructor-arg>
    <constructor-arg ref="MBeanServer" />
</bean>
Nicholas
  • 15,916
  • 4
  • 42
  • 66
  • Ah, sorry for the ref to org.helios.jmx.util.MBeanServerFactory. It's just a call to java.lang.management.ManagementFactory,getPlatformMBeanServer(). – Nicholas Apr 20 '11 at 14:42
  • what should the service url to enter in jConsole look like? – Rihards May 12 '11 at 21:49
  • + I get this exception: `Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mbeanServer' defined in class path resource [META-INF/hw-common-jmx.xml]: No matching factory method found: factory method 'getPlatformMBeanServer()'. Check that a method with the specified name and arguments exists and that it is static. at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:528)` – Rihards May 12 '11 at 22:03
  • Does this mean that the application that is running will start a RMI port such as on 1099? – djangofan Nov 13 '12 at 20:59