How does tomcat correctly turn on remote debugging

Source: Internet
Author: User

In daily development, there are times when remote debugging of applications on remote servers is required, and for Tomcat, remote debugging is simple enough to start the JPDA service when Tomcat is started.

What is JPDA?

JPDA (Java Platform Debugger architecture) is the acronym for the Java Platform Debug architecture, and with the API provided by JPDA, developers can easily and flexibly build Java debugging applications. The JPDA consists of three main components: Java Virtual Machine Tool Interface (JVMTI), Java Debug Line Protocol (JDWP), and Java Debugging Interface (JDI). And, like Eclipse and idea, the development tool provides the graphical interface debugging tool, actually realizes the JDI. For more information on JPDA, you can view a series of articles on Developerworks--Deep Java debugging system

Tomcat starts JPDA using the following method:

./catalina.sh JPDA Start
By default, the default port for remote debugging is 8000, which can be configured by jpda_address, specify a custom port, and two parameters that can be configured

Jpda_transport: The way data is transmitted between the debugger and the virtual machine, and the default value is Dt_socket jpda_suspend: whether the JVM hangs immediately after it is started, and the default is n

Can be configured in catalina.sh:

Jpda_transport=dt_socket
jpda_address=5005
jpad_suspend=n
or configured via jpda_opts:

jpda_opts= '-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 '
After this start, you can use eclise or idea for remote debugging, idea how to do remote debugging, please refer to another article.

There are many articles on the web that provide another way to turn on remote debugging, that is, to specify the corresponding JPDA parameters by java_opts:

java_opts= "$JAVA _opts-xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
Using this method to turn on remote debugging, there is nothing wrong with booting, and you can perform remote debugging normally, but when you stop Tomcat:

./catalina.sh Stop
The following error occurs:

Error:transport error 202:bind failed:address already
in-use ERROR:JDWP transport-Dt_socket failed to initialize, Transport_init (510)
JDWP exit Error Agent_error_transport_init (197): No transports initialized [debuginit.c:750]
FATAL ERROR in native method:jdwp No transports initialized, Jvmtierror=agent_error_transport_init (197)
Causes the Java process to not terminate normally and requires a manual kill, so you should still turn on the remote debugging feature in the previous way.


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.