Debugging your Tomcat Webapp with Intellij Idea

This guide is not tied to any specific IDE. But I’ll be focusing on Tomcat 8 with Intellij IDEA.

Open up a command window/terminal and cd in to $CATALINA_HOME/bin directory. $CATALINA_HOME is simply the place where you installed or extracted Tomcat. If you have installed Tomcat as a service (ie. through apt-get, dnf or by using a Windows binary executable) you first have to find out the installation path where the Tomcat startup scripts are located.

In Ubuntu, you can do
$ updatedb
$ locate

The output for example will be like


Once you’ve located the, starting the Tomcat server in debug mode is as simple as running
./ jpda run

This will get our tomcat server up and running with a JPDA debugger attached in default JPDA server settings (port 8000).

Now it’s time to connect your IDE to the remote JVM. In Intellij Idea this can be done by creating a new Remote Server Debug configuration.

Open ‘Run/Debug Configurations’ dialog box. Then click on Idea Rmote Configuration Add Button button on the top left to add a new remote configuration. You can keep the default settings as shown in the picture below. Make sure to specify the correct debugging port. The default will be 8000.

Run/Debug Configuration: Tomcat Remote

Click ‘OK’. Then simply run the created configuration from the toolbar.

And we are done!

In case you wanna use a different port, append these two lines to $CATALINA_HOME/bin/

export JPDA_TRANSPORT="dt_socket"
export JPDA_ADDRESS="5005"

If you are still confused, refer to the step by step guide linked below for setting up a remote debug configuration in IDEA:
Debugging Server-side Code through IntelliJ IDEA with BEA Weblogic 8.1

Leave a comment

Your email address will not be published. Required fields are marked *