Tomcat+eclipse Remote Debugging

Source: Internet
Author: User

When you do remote debugging, the configuration under Windows and non- windows Systems is different inTomcat , as follows:

 

The first step, configure Tomcat

One, in the Windows System:

Open the file catalina.batunder %cataline_home%/bin , and add the following line :

set Catalina_opts=-server-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,server=y, suspend=n,address=8787

 

Where address=8787 is the port number that is not being used. There are two ways to connect, for dt_shmem and dt_socket, respectively, for native debugging and remote debugging.

 

Second, in non- Windows systems:

You also need to put the last line in the % cataline_home%/bin/startup.sh exec "$PRGDIR"/"$EXECUTABLE" start "[email protected]" in the start changes to jpda start. Because the default port is 8000, if the 8000 port is already in use, it needs to be set in the catalina.sh file:jpda_address=8787.

Enter the command startup.sh or catalina.sh jpda start to launch Tomcat.

 

Step two, configure Eclipse

Select Run in Eclipse ? Debug, in the dialog box that pops up, right-click Remote Java application to create a new one, as shown in the following example:

 

 

 

Enter a name for the remote debugging in the "name" input box,Select the project you want to debug in project, and enter the IPthat requires a remote debug project in "Host", which is the IPwhere Tomcat is located, enter the port number set in "Port", such as the 8787set above, and then tick "allow termination of theremote VM ", click"Apply".

After setting up, you can start debugging, about a few steps:

1. Start tomcat(remote), such as the console output "Listening for transport dt_socket at address:8787", which describes the Set success in Tomcat ;

2, in the local set breakpoints, that is, you need to monitor the line of code before the double-click Will appear a small dot;

3, enter the interface, select the items to debug, click "Debug" Can be remote debugging ;

4. When you run to the line of code where you set the breakpoint, you see the light green bar as shown.

 

 

Key operation:

1,F5 and F6 keys are single-step debugging,F5 is to enter the bank code execution,F6 is to execute our code, jump to the next line;

2,F7 is jumping function;

3,F8 is executed to the last.

 

 

Of course, for convenience, you can create a new batch file, if named debug.bat, add the following lines to this file:

 

CD%cataline_home%/bin

Set jpda_address=8787

Set Jpda_transport=dt_socket

set Catalina_opts=-server-xdebug-xnoagent-djava.compiler=none-xrunjdwp:transport=dt_socket,server=y, suspend=n,address=8787

Startup

 

This allows you to run debug.bat when remote debugging is required, or to run the startup.bat file when remote debugging is not required.


Tomcat+eclipse Remote Debugging

Related Article

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.