PDA

View Full Version : Example of using Spring JMX with Tomcat & JDK 1.4?


cunparis
Mar 23rd, 2006, 10:53 AM
I finally got my application working with MX4J & MC4J using a unit test and now I'd like to get it working as a webapp. I reduce my spring conf down to the bare minimum as described in the documentation:


<bean id="exporter"
class="org.springframework.jmx.export.MBeanExporter">
<property name="autodetect" value="true" />
<property name="beans">
<map>
<entry key="bean:name=testDispatcherSinglethreaded1"
value-ref="testDispatcherSinglethreaded" />
</map>
</property>
</bean>


I have mx4j 3.0.1 & mv4j-remote jars in my project. When I launch tomcat, my spring singletons are never initialized. If I comment the exporter bean, then it works fine (but no JMX). The docs are a little light on this, I've read them probably 10 times. If anyone has a suggestion I'd be very interested.

Thanks,
Michael

Costin Leau
Mar 24th, 2006, 02:13 AM
You can mark the exported as not lazy and see what happens. Are your singleton lazy or not? Are you trying to use them and they don't work or you don't see the logs as your normally do?

cunparis
Mar 24th, 2006, 08:53 AM
You can mark the exported as not lazy and see what happens. Are your singleton lazy or not? Are you trying to use them and they don't work or you don't see the logs as your normally do?

I didn't post everything but I have:


<beans default-lazy-init="false">


At the top of the file. Our singletons are not lazy and have init methods which start threads. Without JMX everything starts and we see the debug output in the logs. With JMX, tomcat starts up but our singletons (and threads) do not.

Costin Leau
Mar 24th, 2006, 09:20 AM
Strange - sounds like a bug. Can you please raise an issue on JIRA? Don't forget to mention your configuration and if possible make a test that proves the problem. Btw, have you been able to reproduce the problem outside Tomcat?

cunparis
Mar 24th, 2006, 11:35 AM
Ok, found out that someone else had set lazy-init to true so that's why our beans weren't working. Finally got that settled. Now the beans start. The problem is I don't know how to access the JMX of tomcat. I try to use MC4J but that doesn't work. I'm using Tomcat 5.5.19 & JDK 1.4 and it seems that JMX of Tomcat 5.5 only works for JDK 1.5. I'm going to take this issue to the MC4J mailing list as I think the spring part is working correctly.

-Michael

Costin Leau
Mar 24th, 2006, 11:38 AM
in order to use jmx on tomcat in a 1.4 jvm you need to download a compatibility jar (namely mx4j) which you can find on tomcat website. The zip includes a readme file which explains what you need to do.

cunparis
Mar 27th, 2006, 03:56 AM
in order to use jmx on tomcat in a 1.4 jvm you need to download a compatibility jar (namely mx4j) which you can find on tomcat website. The zip includes a readme file which explains what you need to do.

The release notes don't explain much of anything. They only mention the jmx.jar, which gets unzipped in the tomcat/bin directory.

Everything starts up ok, I just can't connect with MC4J.

Costin Leau
Mar 27th, 2006, 04:10 AM
I just can't connect with MC4J.
You can't find the jmx server or you can't connect to it? You can track your problems by using some other jmx console - you can find a very simple one on google (based on a servlet). Turn on logging and make sure the exported is started and see the id of the jmx server. the JMX package also offers some utils classes which you can use to do some simple tests to find your jmx server.
Also, don't forget to read the old threads from this forum - the mc4j/tomcat combo has been discussed quite a number of times.

cunparis
Apr 19th, 2006, 12:19 PM
I want to update this thread with my results: I did not find a way to make JMX work with Tomcat 5.5 & JDK 1.4, so I use JDK 1.5 to run Tomcat.

This is for dev, my real production server will be websphere 6 which uses JDK 1.4, so I still have to figure this part out..