How to enable Tomcat to start in Debug mode and Tomcat Debug mode

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.