Tongweb, Tomcat remote debugging

      In the development process, it is often necessary to trace and test the programs deployed remotely. We often print out the information in the form of logs, which is very inefficient for debugging, so it is necessary to use remote debugging.
     1. Tomcat remote debugging configuration
     First find the catalina.bat file in the tomcat/bin/ directory. Then add the following settings to the file: SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket ,server=y,suspend=n,address=5888
     Of course SET CATALINA_OPTS variable should be before using it. This is to set some virtual machine parameters when tomcat starts, so that the server allows the remote connection function. address=5888 indicates the port number of the remote connection, which can be set to any other non-conflicting port.
     SET CATALINA_OPTS variable should refer to before using it (see rem-----Execute The Requested Command ------------------ in clatalina.bat file One line of content, just put the above settings on top of this line.

     Restart tomcat, you can start it independently, instead of starting in the eclipses plug-in. Open the debug settings window in eclipse, select Remote Java Application, create a new debug item, enter the server IP (if it is a local machine, enter localhost or 127.0.0.1) and the port number just set, click ok to enter the debug state.
     However, note that under Linux, there is a slight difference, which is to edit the catalina.sh file. And change it to this: CATALINA_OPTS="-server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5888"
     2.TongWeb remote debugging configuration

     Modify the tongserver file in the bin directory, open it with UE or Notepad, find the JAVA_OPTS line, and change the value to

JAVA_OPTS="${JAVA_OPTS} -Djava.endorsed.dirs=${ENDORSED_DIR} -server -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8884,server=y,suspend=n"

      Debug method

  Start the web container, if your configuration is successful, you will see in the startup information

   Listening for transport dt_socket at address: the port number you set

   Open Eclipse, right-click on the project to be debugged, select " Debug Configurations", then open the dialog box (as shown in the figure below), at this time, the project you will debug is displayed in the project, and fill in the remote host IP in Host, Port fill in the port number you configured above, and tick "Allow termination of remote VM". At this point, you can set breakpoints in the code just like you do locally for remote debugging.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326607591&siteId=291194637
Recommended