Tomcat

Table of Contents

Tomcat and JMX

The MC4J Application supports connections to Tomcat 4.1, 5.0 and now also support version 5.5 servers. Tomcat has a number of managed beans in it and MC4J exposes them.

Connecting MC4J to Tomcat 5.5

Tomcat 5.5 now utilizes the built-in remote protocol of J2SE 5.0 (JDK 1.5). This means that if you run Tomcat with JDK 1.5, you can automatically expose your Tomcat server for remote management with JMX. In order to expose these features, alter your catalina.bat or catalina.sh to set the JAVA_OPTS variable with the value -Dcom.sun.management.jmxremote.port=9004. To connect MC4J to a Tomcat instance, simply select the Tomcat 5.5+ connection type when creating your server connection and alter the connect url to utilize the port set above in your catalina start file.

You'll also need to configure you 1.5 JVM for JMX remoting. This typically involves setting up the password system and disabling SSL (MC4J does not yet support SSL). For the passwords, you'll usually copy "jmxremote.password.template" in your jre's "lib/management" dir to "jmxremote.password" and setup the password you wish to use. Then edit the management.properties file in the same dir to disable the SSL requirement as described in the files comments.

Setting up Tomcat 5.0

The Tomcat developers have decided to no longer support the MX4J proprietary JMX connector on Tomcat 5.0 (http://issues.apache.org/bugzilla/show_bug.cgi?id=27894). They now recommend running Tomcat 5.0 on a 1.5 JVM and using the built-in JMX remoting connector. Follow the directions as described above for Tomcat 5.5.

Setting up Tomcat 4.1

To connect MC4J to Tomcat 4.1 you must first enable the remote RMI management within a Tomcat server. The following steps worked for me:

Edit jk2.properties and add a line "mx.port=9000"
Edit server.xml, enable the Connector under "Coyote/JK2 AJP 1.3 Connector on port 8009"
Copy mx4j-tools.jar from your MX4J distribution and copy it to $CATALINA_HOME/common/lib directory.
Start using "catalina run" - makes it easy to look for any exceptions.

Tests

This has only been tested with Tomcat 4.1.24, 4.1.29 and Tomcat 5.0.18.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Sep 06, 2005

    Anonymous says:

    When I add -Dcom.sun.management.jmxremote.port=9004 to the JAVA_OPTS in catali...



    When I add -Dcom.sun.management.jmxremote.port=9004 to the JAVA_OPTS in catalina.bat tomcat doesn't start. The Tomcat window pops up and then goes away. Hmm...........

    1. Sep 06, 2005

      Anonymous says:

      I'm using 5.5.9.



      I'm using 5.5.9.

      1. Oct 28, 2005

        Brian O'Rourke says:

        This is probably due to your not setting up a JMX password file correctly. Tom...

        This is probably due to your not setting up a JMX password file correctly. Tomcat won't alert you about these startup errors because of this bug:

        http://issues.apache.org/bugzilla/show_bug.cgi?id=35635

        To resolve, try just running

        java -Dcom.sun.management.jmxremote.port=9004

        See if you get any errors - that's probably what's preventing Tomcat from even getting started.

  2. Oct 12, 2005

    Hack Kampbjorn says:

    The instructions for setting up a 5.0.x Tomcat did not work for me with Tomcat...

    The instructions for setting up a 5.0.x Tomcat did not work for me with Tomcat 5.0.30. The problem is similar to the description of this bug: http://issues.apache.org/bugzilla/show_bug.cgi?id=27894

    The sugestion of using the JDK 1.5 JMX implementation worked with the Tomcat 5.5.x instructions. After reading the SUN documentation http://java.sun.com/j2se/1.5.0/docs/guide/management/agent.html

  3. Oct 12, 2005

    Chuck Sumpter says:

    Has anyone actually gotten Tomcat 4.1.xx (I tried 27 and 29) to work. I've tri...

    Has anyone actually gotten Tomcat 4.1.xx (I tried 27 and 29) to work. I've tried everything suggested here, in the Apache lists and on the sun site. The difference may be the os (Win2003), but that seems unlikely.

    Tomcat5.5.9 (with Java 1.5) is a snap, but it will be a few weeks till we migrate to that.

    Anyone, anyone, Buehler?

  4. Dec 05, 2005

    Heidi Yeung says:

    I have successfully connected to Tomcat 5.0.28 server by MC4J in...

    I have successfully connected to Tomcat 5.0.28 server by MC4J in Window XP. These are the steps:

    JDK setup
    1) JDK MUST be 5.0
    2) Go to "JAVA_HOME/jre/lib/management/" and change copy the file "jmxremote.password.template" to "jmxremote.password"
    3) Open "jmxremote.password" and uncomment both
         monitorRole  QED
         controlRole   R&D
    4) Open "management.properties", uncomment "com.sun.management.jmxremote.ssl=false" to disable "SSL"

    Tomcat Setup
    1) The path of Tomcat SHOULD be NO space (e.g. C:\Tomcat5). Otherwise, JMX service cannot be loaded.
    2) Stop Tomcat
    3) Move "log4j-1.2.8.jar", "mx4j-jmx-1.1.1.jar", "mx4j-tools-1.1.1.jar" from "MC4J_HOME/mc4jlib" and "MC4J_HOME/mc4jlib/MX4J" to "TOMCAT_HOME/common/lib"
    4) Add the following text into "TOMCAT_HOME/conf/jk2.properties" to enable JMX by Tomcat
        #JMX mit MX4J JRMP Adapter
        mx.port=8999
        mx.enabled=true
        mx.jrmpPort=8999 #the connection port
        mx.jrmpHost=localhost
    5) Start Tomcat by "TOMCAT_HOME/bin/startup.bat", if you use services, the JMX may not be started.
    6) See if the following text is shown in Tomcat Console
        2005-12-5 06:50:22pm org.apache.jk.common.JkMX loadAdapter
        info: Creating Naming:name=rmiregistry
        2005-12-5 06:50:23pm org.apache.jk.common.JkMX loadAdapter
        info: Creating Adaptor:protocol=jrmp on host localhost at port 8999
        log4j:WARN No appenders could be found for logger (org.apache.log4j.jmx.HierarchyDynamicMBean).
        log4j:WARN Please initialize the log4j system properly.
        2005-12-5 06:50:23pm org.apache.jk.common.JkMX init
        info: Registering the JMX hierarchy for Log4J
        2005-12-5 06:50:23pm org.apache.jk.server.JkMain start
        info: Jk running ID=0 time=0/832  config=C:\Tomcat5\conf\jk2.properties
        2005-12-5 06:50:23pm org.apache.catalina.startup.Catalina start
        info: Server startup in 6049 ms
    7) Go to command prompt, use "netstat -a" to see whether 8999 is one of listening port

    MC4J Setup
    1) Finally, use MC4J to connect the Tomcat JMX Service, give a name and select "MX4J 1.x" from the connection type combo box
    2) JNDI Name is "jrmp", Initial Context Factory is "com.sun.jndi.rmi.registry.RegistryContextFactory"
    3) Server URL is "rmi://localhost:8999" (if this is local server)
    4) The Server should be connected and show the green light

  5. May 17, 2006

    Steve Whatmore says:

    Does anyone have explicit instructions for getting MC4J to work with Tomcat 5.5....

    Does anyone have explicit instructions for getting MC4J to work with Tomcat 5.5.17 on Windows?

    I have had success with AdventNet ManageEngine Applications Manager 6 by enabling JMX using the environment variable

                PR_JvmOptions=-Dcom.sun.management.jmxremote

    but no luck so far with MC4J