Jetty How To

 

This page describes how to enable Zapcat in a Jetty application server.


Jetty’s forte is that is is highly customisable. That means that you probably won’t find many stock Jetty configurations out there. You may have to view these instructions as a guideline rather than a step-by-step tutorial.


Before You Begin

In this tutorial, I expect that you have both Zabbix and Jetty up and running. For this tutorial, I use a stock Jetty 6.1 installation, freshly downloaded.




Enabling JMX

Before we can look into the JVM, we have to enable JMX. The easiest way to test that is to use jconsole. Incidently, this is a nice example of how you can cherry pick the features you like and need for your Jetty server.


We specify “-Dcom.sun.management.jmxremote” on the command line when we start Jetty to tell the JVM to create an mbeans server.

% java -Dcom.sun.management.jmxremote -jar start.jar etc/jetty.xml


This enables JMX on the application server’s JVM, but we can go a little further by configuring Jetty with its JMX management extensions. This will cause Jetty to register a few Jetty-specific mbeans.


Open the Jetty configuration file, “etc/jetty.xml”, with your favourite XML or text editor. Near the closing tag of the file, paste the configuraiton shown below. Note that this sample was taken from “etc/jetty-jmx.xml”. You can take a look at that file for more details.

    <!-- Use the jdk 1.5 platformMBeanServer -->

    <Call id="MBeanServer"

        class="java.lang.management.ManagementFactory"

        name="getPlatformMBeanServer"/>


    <Get id="Container" name="container">

      <Call name="addEventListener">

        <Arg>

          <New class="org.mortbay.management.MBeanContainer">

            <Arg><Ref id="MBeanServer"/></Arg>

            <Call name="start" />

          </New>

        </Arg>

      </Call>

    </Get>


Restart Jetty with the new configuration and test it by starting jconsole on the same machine as the JVM. Jconsole will pick up on the instrumented JVM automatically.


If you experiment with different configurations for your Jetty server, you will notice that each extension has its own mbeans.


Deploying Zapcat

With JMX enabled you can deploy Zapcat’s web application in Jetty. Copy the WAR file from the Zapcat distribution and place it in Jetty’s directory named “webapps”. When you start Jetty, you will see that it automatically picks up on the web application. The Zapcat agent is now running in Jetty, ready to be used. If you like, you can open a browser to have a look at the front page of Zapcat.


Jetty MBeans

Jetty does not have an impressive list of mbeans to show off. There are a few mbeans that provide some insight into each of the configured components and extensions you have in use.


Start the configuration of your monitor by applying the Java template for Zabbix. If your application uses Hibernate, you can apply the Hibernate template as well.


I am very interested in hearing about Jetty servers that are being monitored. If you would be so kind as to share your host configuration file for Zabbix, that would be even better.

 
photo: Vangelis Thomaidishttp://www.sxc.hu/profile/forwardcom
if you find this interesting, terrible or just would like to know more, e-mail memailto:kjkoster@kjkoster.org?subject=
web statistics
download zapcathttp://sourceforge.net/project/showfiles.php?group_id=209024
http://java-monitor.com/