View Full Version : Need help with JMX, Spring, Tomcat, & MC4J
cunparis
Apr 6th, 2006, 12:04 PM
I'm using Spring 1.2.7, Tomcat 5.5.16, & JDK 1.5. I start up tomcat with these options:
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.port=8999
-Dcom.sun.management.jmxremote
My spring JMX conf looks like this (from the reference docs):
<bean id="exporter" class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=testBean1" value-ref="testBean"/>
</map>
</property>
</bean>
<bean id="testBean" class="org.springframework.jmx.JmxTestBean">
<property name="name" value="TEST"/>
<property name="age" value="100"/>
</bean>
For MC4J, I use the Tomcat option with this:
service:jmx:rmi:///jndi/rmi://localhost:8999/jmxrmi
I connect just fine, but I don't see my spring beans.
Our target platform is WebSphere but we use Tomcat for development. I'd like to come up with something that will work on both. It's ok if I have two separate confs for each server.
Thanks to anyone who can help.
-Michael
cunparis
Apr 7th, 2006, 05:18 AM
This is all I see in the logs:
11:05:19,929 [ain Thread] INFO [MBeanExporter ] - Bean with name 'swGenerateurMetDispatcher' has been autodetected for JMX exposure
11:05:19,945 [ain Thread] DEBUG [MBeanExporter ] - Located MBean under key [swGenerateurMetDispatcher]: registering with JMX server
11:05:19,945 [ain Thread] DEBUG [MBeanExporter ] - Unable to register MBean [canal.det.service.workflow.mege2med2met.impl.SWGen erateurMetDispatcherImpl@343829] with key [swGenerateurMetDispatcher]
Costin Leau
Apr 7th, 2006, 06:33 AM
mark the exporter as non lazy - lazy-init="false".
cunparis
Apr 7th, 2006, 07:53 AM
mark the exporter as non lazy - lazy-init="false".
I had that defined as default..
Here is the file with it added again:
<beans default-lazy-init="false">
<bean id="exporter"
class="org.springframework.jmx.export.MBeanExporter"
lazy-init="false">
<property name="autodetect" value="true" />
</bean>
</beans>
Is there a Spring mailing list? I don't find mention of one on the website. I'm really stuck here, I am afraid I'll have to code up the JMX by hand because I can't get this working.
Thanks for your help.
Costin Leau
Apr 7th, 2006, 09:35 AM
Yes - the lists are listed here : http://sourceforge.net/mail/?group_id=73357 (from the development page).
The log mention that the bean could not be registered - I'm not sure however why this happens since Spring only calls the underlying server. The samples included in the Spring distribution contain jmx support - use them and see how they work - you might spot some mistake somewhere.
cunparis
Apr 7th, 2006, 09:51 AM
Working now, apparently it was the example in the documentation not having lazy-init="false". I'll open a JIRA issue for that.
Now I'm finding that the InterfaceBasedMBeanInfoAssembler is not working..
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans default-lazy-init="false">
<bean id="exporter"
class="org.springframework.jmx.export.MBeanExporter">
<property name="beans">
<map>
<entry key="bean:name=detCalendar" value-ref="detCalendar" />
<entry key="bean:name=swDepileurMegST"
value-ref="swDepileurMegST" />
<entry key="bean:name=swDepileurMegEM"
value-ref="swDepileurMegEM" />
</map>
</property>
<property name="assembler">
<bean
class="org.springframework.jmx.export.assembler.Interface BasedMBeanInfoAssembler">
<property name="interfaceMappings">
<props>
<prop key="detCalendar">
canal.det.service.technique.DetCalendarMBean
</prop>
<prop key="swDepileurMegST">
canal.det.service.workflow.common.DispatcherMBean
</prop>
<prop key="swDepileurMegEM">
canal.det.service.workflow.common.DispatcherMBean
</prop>
</props>
</property>
</bean>
</property>
</bean>
</beans>
Costin Leau
Apr 7th, 2006, 11:22 AM
What do you mean by not working - what do you expect to happen and does not?
robh
Apr 11th, 2006, 06:18 AM
The 'key' of each properties entry for InterfaceBasedMBeanInfoAssembler should match the 'key' of each entry in the 'beans' Map on MBeanExporter. To simply this I often use a PropertyPlaceholderConfigurer for the keys:
<bean id="exporter" class="..MBeanExporter">
<property name="beans">
<map>
<entry key="${myMBean}" value-ref="someBean"/>
</property>
<property name="assembler">
<bean
class="org.springframework.jmx.export.assembler.Interface BasedMBeanInfoAssembler">
<property name="interfaceMappings">
<value>
${myMBean}=com.myapp.someInterface
</value>
</property>
</bean>
</property>
</bean>
In the PropertyPlaceholderConfigurer the property 'myMBean' is mapped to the ObjectName.
Rob
cunparis
Apr 20th, 2006, 04:20 AM
Working now, apparently it was the example in the documentation not having lazy-init="false". I'll open a JIRA issue for that.
Issue opened:
http://opensource.atlassian.com/projects/spring/browse/SPR-1935
gmatthews
Apr 20th, 2006, 06:35 PM
I hope you can sort it out, but if you really get stuck, you can use JBoss.
It has Tomcat 5.5.x embedded, and you don't need to faff about with MX4J since JBoss already has an MBeanServer built in, incl. JMX console.
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.