Simplest way of accessing a Spring-exported JMX bean on Websphere 7.0

陌路散爱 提交于 2019-12-12 06:58:47

问题


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 ?


回答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>


来源:https://stackoverflow.com/questions/5726720/simplest-way-of-accessing-a-spring-exported-jmx-bean-on-websphere-7-0

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!