How to Run Jetty with jconsole
All you need do is start jconsole and then start jetty with a special system property:
If you are running the jetty maven plugin, then you need to start it like so:
You should see a dialog like so (Note that with the jetty maven plugin, there entry will say "org.codehaus.classworlds.Launcher "jetty:run"" instead):
Select the start.jar entry and click on the
Connect button.A new jconsole window will open:
From this window you will be able to monitor memory usage, thread usage, classloading and vm statistics. You'll also be able to perform operations such as doing a manual garbage collect. Jconsole is an extremely powerful and useful tool.
Using the Jetty mbeans with jconsole
If you also want to be able to interact with the Jetty JMX implementation via jconsole, edit the
etc/jetty-jmx.xml file, find the following lines and comment out the first one, and uncomment the second one so the lines look like:
This forces Jetty to use the default MBeanServer provided by Sun in the java runtime. Then start jetty as shown above.
Alternatively, you can configure Jetty to use a different mbean server than the default one. This requires a remote connector definition in the
etc/jetty-jmx.xml file. There is one already provided for you that you only need to uncomment. Find and uncomment the following lines:
Then, you will need to ensure that you have the
rmiregistry running. The start sequence becomes:
You then need to configure jconsole to find this remote connector. Click on the
Advanced panel and enter the connector url like so:
Connect button and you will be able to manipulate the Jetty mbeans.
Jetty Maven Plugin
To be able to manipulate the jetty mbeans with jconsole, you need to provide the contents of the
etc/jetty-jmx.xml to the plugin as a <jettyConfig> element.