Tomcat Remote Debugging Eclipse

When you use eclipse to develop a web application and deploy it into a remote tomcat server, how to debug the remote deployed web application to fix bugs? This article will tell you how to do it. This example will use Spring Tool Suite ( based on eclipse ) and tomcat server version 9.

1. Start Tomcat In Remote Debug Mode.

First you need to start the tomcat server in JPDA mode, this mode can make the tomcat server remote connected from a eclipse project.

  1. CD into TOMCAT_HOME/bin folder in a terminal window.
  2. Run su to change to root user in Linux or MacOS.
  3. Run ps -ef|grep tomcat to see whether the tomcat server is running or not.
  4. If tomcat is running, run to stop it.
  5. Run jpda run command to start tomcat server in debug mode.
  6. When you see output in the terminal window like below message, it means tomcat server has been started in debug mode successfully, it listens on port 8000.
    Listening for transport dt_socket at address: 8000
    Server startup in *** ms

2. Debug Java Web Application From Eclipse.

After deploy your java web application in tomcat server, you can now debug the code from eclipse.

  1. Click Run —> Debug Configurations… menu item in the eclipse top menu bar.
    eclipse run debug configurations menu item
  2. Select Remote Java Application item in left panel. Then click add icon eclipse configuration new item icon  at top left to add a new configuration, and input correct connection properties such as Host ( localhost ) and Port ( 8000 ).
    add a new remote java application debug configuration
  3. Then click Apply button to save the settings. Click Debug button to begin debug project code with the web application deployed in the remote tomcat server. You can set breakpoint in your project source code, when application run into the breakpoint, the execution will be paused, then you can watch the variables values.

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.