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:
- 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).
- 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:
- Xdebug: indicates that debug mode is enabled.
- 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).
- Save and close the startup script.
- Start Tomcat and wait for it to finish starting up.
- 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.