Configuring JSW + embedded Jetty with JMX
I thought I’d share this knowledge that I’ve learned while migrating our project to be distributed in a Jetty bundle JMX (see java.sun.com/javase/technologies/core/mntr-mgmt/javamanagement/)
I’ve summarized this into the following steps:
1. You must have a jetty-jmx.xml file with the following configuration:
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">
<Configure id="Server" class="org.mortbay.jetty.Server">
<!– =========================================================== –>
<!– Initialize an mbean server –>
<!– =========================================================== –>
<!– Use the jdk 1.5 platformMBeanServer –>
<Call id="MBeanServer" class="java.lang.management.ManagementFactory" name="getPlatformMBeanServer"/>
<!– =========================================================== –>
<!– Initialize the Jetty MBean container –>
<!– =========================================================== –>
<Get id="Container" name="container">
<Call name="addEventListener">
<Arg>
<New class="org.mortbay.management.MBeanContainer">
<Arg><Ref id="MBeanServer"/></Arg>
<!– If using < jdk1.5 uncomment to start http adaptor –>
<!– Set name="managementPort">8082</Set –>
<Call name="start" />
</New>
</Arg>
</Call>
</Get>
</Configure>
2. In your wrapper.conf file, add the jetty-jmx.xml file in the Application Parameters section like the following:
wrapper.app.parameter.1=org.mortbay.start.Main
wrapper.app.parameter.2=[PATH_TO_JETTY_CONFIG]/jetty-jmx.xml
wrapper.app.parameter.3=[PATH_TO_JETTY_CONFIG]/jetty.xml
3. Add also the following in the Java Additional Parameters section of the wrapper.conf:
wrapper.java.additional.7=-Dcom.sun.management.jmxremote.ssl=false
wrapper.java.additional.8=-Dcom.sun.management.jmxremote.authenticate=false
wrapper.java.additional.9=-Dcom.sun.management.jmxremote.port=9999
4. Start the Jetty bundle by invoking the startup script for the JSW.
5. To see if JMX was enabled, use jconsole to connect. In jconsole, create a new connection and in the Advanced tab, provide the following JMX url then click Connect:
service:jmx:rmi:///jndi/rmi://127.0.0.1:9999/jmxrmi
After step 4, you should be able to see the Memory, Threads, Classes and MBeans info of your application.
Specifics for the tools used above:
- appassembler-maven-plugin 1.0-beta-2
- java 1.5.0_11
- jetty 6.1.11
- jsw 3.2.3
- BROWSE / IN TIMELINE
- « Continuum 1.3.1 (Alpha) now released!
- » “Managing Your Repositories with Archiva” @ApacheCon Europe 2009
- BROWSE / IN Tech blogs
- « Continuum 1.3.1 (Alpha) now released!
- » “Managing Your Repositories with Archiva” @ApacheCon Europe 2009
SPEAK / ADD YOUR COMMENT
Comments are moderated.

