How to enable Tomcat to start in Debug mode and Tomcat Debug mode
Sometimes we need to remotely Debug the project code, which requires Tomcat to be started in Debug mode.
Environment Description
Windows 7 64-bit
JDK 8 64-bit
Tomcat-8.0.21 x64.zip
Step 1: Configure JPDA Parameters
If Tomcat is JDK 1.5 or later, JPDA can use JVMDI. The configuration method is as follows:
Add the following content to the bin/catalina. bat file of tomcat:
Set JPDA_OPTS =-agentlib: jdwp = transport = dt_socket, server = y, suspend = y, address = Local host: 8000
For Mac OS X or Linux, add the following content to the bin/catalina. sh file:
Export JPDA_OPTS =-agentlib: jdwp = transport = dt_socket, server = y, suspend = y, address = Local host: 8000
The port in address is not necessarily 8000, but can be changed to another port.
If JDK 1.4 is used, only JVMPI can be used. For more information, see the following description.
Step 2: Start In JPDA Mode
Add JPDA to the startup command in the bin/startup. bat file of tomcat, for example:
Note:
1) the above methods have passed the test in Windows/Mac OS X and Tomcat 5.5.25. For details about Tomcat 5.0.x and 6.0.x, see the 4 th floor;
2) for JDK 1.4, the JPDA parameter must be adjusted to-Xdebug-Xrunjdwp: transport = dt_socket, server = y, suspend = y, address = localhost: 8000, but you have not tried it, some parameters may need to be adjusted. (JDK 1.5 is recommended because JVMDI is much more powerful than JVMPI)
3) JPDA parameters are described in http://java.sun.com/j2se/1.5.0/docs/guide/jpda/conninv.html.
4) debug is not the only method for diagnosing and solving problems. It is often used to analyze the running logs to quickly identify the cause and solve the problem.