Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Jetty/Howto/Run Jetty with JConsole

< Jetty‎ | Howto
Revision as of 17:15, 26 April 2013 by Jesse.mcconnell.gmail.com (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)



Introduction

Warning2.png
Jetty 7 and Jetty 8 are now EOL (End of Life)




THIS IS NOT THE DOCUMENTATION YOU ARE LOOKING FOR!!!!!






All development and stable releases are being performed with Jetty 9 and Jetty 10.






This wiki is now officially out of date and all content has been moved to the Jetty Documentation Hub






Direct Link to updated documentation: http://www.eclipse.org/jetty/documentation/current/jetty-jconsole.html


JConsole is a graphical tool; it allows you to remotely manage and monitor your server and web application status using JMX. When following the instructions given below, please also ensure that you make any necessary changes to any anti-virus software you may be using which may prevent jconsole from running.

Monitoring Jetty with JConsole

To monitor Jetty's server status with JConsole, make sure JConsole is running, and start Jetty with a special system property.

Starting Jetty Standalone

This is straightforward from the command line, when running the standalone Jetty binary.

 java -Dcom.sun.management.jmxremote -jar start.jar  etc/jetty-jmx.xml
 jconsole &        # runs jconsole in the background 

You might also want to consult the section on configuring the start.ini file to clean up the command line, and apply these options to all subsequent jetty invocations.

Starting the Jetty Maven Plugin

If you are running the Jetty Maven Plugin, you must set the system property com.sun.management.jmxremote on Maven before running the plugin. The way to do this is to set your MAVEN_OPTS environment variable (if you're not sure how to do this, consult the Maven documentation).

Here is an example that sets the system property on the fly in a BASH shell, before starting Jetty via the plugin:

 export MAVEN_OPTS=-Dcom.sun.management.jmxremote
 mvn jetty:run
 jconsole &        # runs jconsole in the background 

Connecting to your server process

When you start Jetty, you see a dialog box from JConsole with a list of running processes to which you can connect. It should look something like so:

New connection dialog box in JConsole

Idea.png
Finding your process
If you don't see your Jetty process in the list of processes you can connect to, quickly switch tabs, or close and reopen a new "New Connection" dialog window. This forces JConsole to refresh the list, and recognize your newly-started Jetty process.


Select the start.jar entry and click the "Connect" button. A new JConsole window opens:

Jconsole2.jpg

From this window you can monitor memory usage, thread usage, classloading and VM statistics. You can also perform operations such as a manual garbage collect. JConsole is an extremely powerful and useful tool.

provided

Managing Jetty Objects with JConsole

The MBean tab of JConsole allows access to managed objects within the Java application, including MBeans the JVM provides. If you also want to interact with the Jetty JMX implementation via JConsole, you need to start Jetty JMX in a form that JConsole can access.

Starting Jetty Standalone

Starting the Jetty server is straightforward, but requires two additional arguments:

  • The OPTIONS=default,jmx start option to load the JMX-related JARs.
  • The etc/jetty-jmx.xml configuration, to configure the JVM JMX Server.
   java -Dcom.sun.management.jmxremote -jar start.jar OPTIONS=default,jmx etc/jetty-jmx.xml etc/jetty.xml [more config files]
   jconsole &

Starting the Jetty Maven Plugin

The easiest way to start the Jetty Maven Plugin is to supply the etc/jetty-jmx.xml file in the plugin configuration:

<plugin>
  <groupId>org.mortbay.jetty</groupId>
  <artifactId>jetty-maven-plugin</artifactId>
  <configuration>
    ...
    <jettyConfig>/path/to/jetty-jmx.xml</jettyConfig>
    ...
  </configuration>
</plugin>
Note.png
Merging with existing configuration files
If you already have a Jetty configuration file that you use with the plugin, you can merge the contents of etc/jetty-jmx.xml with it.


Then, just as above, start JConsole and Jetty:

 export MAVEN_OPTS=-Dcom.sun.management.jmxremote
 mvn jetty:run
 jconsole &        # runs jconsole in the background

Copyright © Eclipse Foundation, Inc. All Rights Reserved.