Maven, Jetty and IntelliJ Debugging

We run applications with Jetty during our development process and it’s useful to be able to link up a debugger while the application is running.

Since Jetty is launched from maven we need to do the following:

  1. From your prompt run the following command to allow you to connect to the application remotely.Post JDK1.3.x
    export MAVEN_OPTS=”-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005″

    Pre JDK1.3.x
    export MAVEN_OPTS=”-Xnoagent -Djava.compiler=NONE -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005″

  2. Go to IntelliJ and click on Run -> Edit Configurations. Then click on the + button followed by Remote to add a remote configuration. Make sure you are listening on the right port (5005) and click apply.When you start Jetty from Maven you will see – Listening for transport dt_socket at address: 5005
  3. Then you go into IntelliJ, choose the Remote configuration that you have just set up, and press debug. Now you can set breakpoints and debug the code.

Update 7th May: As it turns out, you can also run jetty using “mvnDebug jetty:run” which has the same effect. Just remember to choose the correct socket address in the IntelliJ configuration.


You can leave a response, or trackback from your own site.

Leave a repsonse

  1. * Required fields