Remote debugging configuration in Tomcat and eclipse

Source: Internet
Author: User

During remote debugging, configurations in windows and non-Windows systems are different in Tomcat, as shown in the following code:

Step 1: Configure Tomcat
1. In Windows:
Open the file Catalina. bat under % 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

Address = 8787 is the unused port number. There are two Connection Methods: dt_shmem and dt_socket, which indicate local debugging and remote debugging respectively.

2. In non-Windows systems:
Change start in EXEC "$ prgdir"/"$ executable" start "$ @" in % cataline_home %/bin/startup. Sh to JPDA start. Because the default port is 8000, if port 8000 already exists, set jpda_address = 8787 In the Catalina. Sh file.

Run startup. Sh or Catalina. Sh JPDA start to start Tomcat.

Step 2: Configure eclipse
In eclipse, select rundebug. In the displayed dialog box, right-click Remote Java application to create a remote debugging item, as shown in the following figure:

In the "name" text box, enter the name of the remote debugging, select the project to be debugged in "project", and enter the IP address of the project to be remotely debugged in "host, that is, the IP address of Tomcat. In "Port", enter the set port number, for example, 8787 set above, select "allow termination of remote VM", and click "Apply.

After the settings are complete, you can start debugging. There are several steps:
1. Start Tomcat (remote). If "listening for transport dt_socket at address: 8787" is output on the console, the setting is successful in Tomcat;

2. Set a breakpoint on the local machine, that is, a small dot appears when you double-click the code line to be monitored;
3. Go to the interface, select the item to be debugged, and click "debug" to perform remote debugging;
4. When you run the code line with the breakpoint configured, you can see the light green lines shown in.

Button operation:
1. Both F5 and F6 are single-step debugging. F5 is executed in the code of the line, F6 is executed in the code of the line, and jumped to the next line;
2. F7 is a jump function;
3. F8 is executed until the end.

Of course, for convenience, you can create a new batch processing file. If it is named Debug. bat, add the following lines to the 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

In this way, you can run Debug. bat when remote debugging is required. You can run the startup. BAT file when remote debugging is not required.

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.