PDA

View Full Version : How can I browse mbeans exported by spring in a console app


Anonymous
Oct 4th, 2005, 03:52 AM
I have add mbeanserver to my app like this

<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactory Bean"/>

<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=hellor1" value-ref="hellor1"/>
<entry key="bean:name=httpConnector">
<ref local="httpConnector"/>
</entry>
</map>
</property>
<property name="server" ref="mbeanServer"/>
</bean>

and I have added -Dcom.sun.management.jmxremote to the jvm parameters
when the app starts, spring framework's log claims that the server has been created and the mbeans have been created.
when I connect to the app through Jconsole. It connected successfully but none of spring created mbean is show. Only jdk's mbeans are there.
On the other hand, if I use Jconsole to connect to a tomcat server which has spring web apps deployed, Jconsole does show all the mbeans. :shock:
What is wrong?Plean help me

siberian
Oct 4th, 2005, 04:07 AM
Hi, I have worked it out.
Simply change the mbeanserver configuration to
<bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactory Bean">
<property name="locateExistingServerIfPossible" value="true"/>
</bean>
and it works.
I belive -Dcom.sun.management.jmxremote tell jvm to create its own mbeanserver, it is this server which Jconsole connected to.
And we need "hook" spring's mbeanserver to jvm's
locateExistingServerIfPossible can do this.

Anonymous
Oct 6th, 2005, 07:25 AM
Hi, I have worked it out.

I do not know how to stop this.

siberian
Oct 8th, 2005, 12:31 AM
Hi, I have worked it out.

I do not know how to stop this.
don't know what you mean. But if you mean my English is poor... Yes.