Contents

Introduction

This tutorial describes how the Jetty JMX integration can be initialized and configured. The simplest way to access the MBeans that are published by Jetty is to use the JConsole utility supplied with Sun's Java Virtual Machine. The steps required to configure Jetty JMX integration will be different depending on the way that Jetty is bootstrapped.

Details

Configuration

Standalone Jetty

When running in standalone mode, the MBeanContainer instance can be configured for a Jetty server by the jetty-jmx.xml configuration file. This can be run with the standard configuration file as follows:

Please note that MBeanContainer is created immediately after the Server is created, and that an MBean is created for it immediately after it is registered as an EventListener of the Server's Container object. Because logging is initialized prior to MBeanContainer, it is necessary to create an MBean for the logger manually as well.

Configure Jetty Maven Plugin

If you are using the Jetty Maven plugin you should copy the etc/jetty-jmx.xml file into your webapp project somewhere, such as src/etc, then add a <jettyconfig> element to the plugin <configuration>:

Custom Monitor Application

You can also write a custom application using JMX API that will monitor your Jetty server. In order for this application to be able to connect to your Jetty server, you will need to un-comment the last section of etc/jetty-jmx.xml configuration file and optionally modify the endpoint name. That will create a JMX HTTP connector and register a JMX URL that it will be output to the Stderr log. You should provide the URL that appears in the log to your monitor application in order to create MBeanServerConnection. See the configuration file for more details.