Tomcat Remote Debugging Setup Guide

To enable remote debugging on Tomcat, you need to add some parameters to Tomcat’s startup script. Here are the specific steps:

  1. Open the startup script of Tomcat, which is typically located in the bin directory as either the catalina.sh file (for Linux) or catalina.bat file (for Windows).
  2. Find the JAVA_OPTS related settings in the startup script, and then add the following parameters:
export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

Alternatively

set JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000

Below are the explanations of the parameters:

  1. Xdebug: indicates that debug mode is enabled.
  2. Specify using the JDWP protocol for remote debugging, listening on port 8000, allowing remote connections (server=y), and not pausing at startup to wait for the debugger connection (suspend=n).
  1. Save and close the startup script.
  2. Start Tomcat and wait for it to finish starting up.
  3. Configure remote debugging in the IDE, set the port to 8000 (or the port number set in the above steps), and connect to the Tomcat server.

Now, you can debug a Tomcat application remotely in the IDE.

bannerAds