Enable tomcat debugging

Shutdown tomcat and make sure that it has properly shut down by monitoring the tomcat process.

Once it has completely shutdown, export the following environment variables:

Here, we’re setting the jpda address to port 8000. Note this down as you will need this port number in order to connect via your IDE or whatever debugging tool you’re using.

Options above will run tomcat as usual so if you want to debug something that happens early on in the lifecycle, you either need to be really quick about attaching your debugger or add the following JPDA option:

This will suspend the tomcat startup until you attach your debugger.

Next, start tomcat jpda using catalina script:

At this stage, you can monitor the log in catalina.out file to make sure everything goes smoothly.

Now setup your IDE to connect to tomcat at port 8000. If you are using vagrant as your VM, make sure you are port forwarding 8000 in your network settings. If not, you can always tunnel in:

Or if its a remote server, you can just use the normal ssh command:

Hope this helps!


  • Conor Restall: For suggesting JPDA_SUSPEND option.

2 thoughts on “Enable tomcat debugging

  1. Nice post. I wish you’d written this about 2 weeks ago when I was trying to debug startup problems with a tomcat app running in docker.

    A useful and common JPDA debug option is JPDA_SUSPEND=y/n. The option will cause tomcat not to start until a debugger is attached.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.