private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery
The Java Management Extensions (JMX) API is a standard API for managing and monitoring resources such as applications, devices, services, and the Java virtual machine.
Typical uses of the JMX technology include:
Consulting and changing application configuration.
Accumulating and making available statistics about application behavior.
Notifying of state changes and erroneous conditions.
The JMX API includes remote access, so a remote management program can interact with a running application for these purposes.
Jetty JMX integration uses the platform MBean server implementation that Java VM provides. The integration is based on the ObjectMBean implementation of DynamicMBean. This implementation allows you to wrap an arbitrary POJO in an MBean and annotate it appropriately to expose it via JMX. See Jetty JMX Annotations.
TheMBeanContainer implementation of the Container.Listener interface coordinates creation of MBeans. The Jetty Server and it's components use a Container to maintain a containment tree of components and to support notification of changes to that tree. The MBeanContainer class listens for Container events and creates and destroys MBeans as required to wrap all Jetty components.
You can access the MBeans that Jetty publishes both through built-in Java VM connector via JConsole, or by registering a remote JMX connector and using a remote JMX agent to monitor Jetty.
This guide describes how to initialize and configure the Jetty JMX integration.
To monitor an application using JMX, perform the following steps:
Configure the application to instantiate an MBean container.
Instrument objects to be MBeans.
Provide access for JMX agents to MBeans.
The simplest way to access the MBeans that Jetty publishes is to use the JConsole utility the Java Virtual Machine supplies. See Jetty JConsole for instructions on how to configure JVM for use with JConsole.
To access Jetty MBeans via JConsole, you must:
Enable the registration of Jetty MBeans into the platform MBeanServer.
Enable a JMXConnectorServer so that JConsole can connect and visualize the MBeans.
Configuring Jetty JMX integration differs for standalone and embedded Jetty.
JMX is enabled by default in the jetty-9 distribution. If you are having difficulties validate that the section in the jetty.home/start.ini file is uncommented.
When running Jetty embedded into an application, create and configure an MBeanContainer instance as follows:
Notice that Jetty creates the MBeanContainer immediately after creating the Server, and immediately after registering it as an EventListener of the Server object (which is also a Container object).
Because logging is initialized prior to the MBeanContainer (even
before the Server itself), it is necessary to register the logger
server.addBean() so that the loggers may
show up in the JMX tree
If you are using the jetty
maven plugin you should copy the
etc/jetty-jmx.xml file into your webapp project somewhere,
src/etc, then add a
<jettyconfig> element to the plugin
There are two ways of enabling remote connectivity so that JConsole can connect to visualize MBeans.
property on the command line. Unfortunately, this solution does not
play well with firewalls and it is not flexible.
ConnectorServer class. To enable use
of this class, uncomment the correspondent portion in
etc/jetty-jmx.xml, like this:
This configuration snippet starts an RMIRegistry and a JMXConnectorServer both on port 1099 (by default), so that firewalls should open just that one port to allow connections from JConsole.
JMXConnectorServer several options to restrict access. For a complete guide to controlling authentication and authorization in JMX, see Authentication and Authorization in JMX RMI connectors in Luis-Miguel Alventosa's blog.
To restrict access to the JMXConnectorServer, you can use this
configuration, where the
jmx.access files have the format specified in the
blog entry above:
Using the JMX API, you can also write a custom application to
monitor your Jetty server. To allow this application to connect to your
Jetty server, you need to uncomment the last section of your
etc/jetty-jmx.xml configuration file and optionally modify
the endpoint name. Doing so creates a JMX HTTP connector and registers a
JMX URL that outputs to the
You should provide the URL that appears in the log to your monitor
application in order to create an
You can use the same URL to connect to your Jetty instance from a remote
machine using JConsole. See the configuration
file for more details.