Tomcat remote debugging

Java Add comments

Sometimes your web applications behave different when deployed to the application server although everything worked fine when running inside Eclipse on your workstation.

In this case it is helpful to remote debug the application. In case of using Tomcat as application server just add the following VM parameters to JAVA_OPTS:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n

I do this inside the file setenv.sh in the bin directory by adding a line JAVA_OPTS=”…options…”

The paramete -Xdebug tells the VM to start in debug mode. -Xrunjdwp selects the protocol. Change the port 8000 to an appropriate value for your server (one that is not used by another process and is reachable). By setting the value suspend=n the VM does not wait until a remote debugging session connects until starting.

Now all you have to to is start the server and run a remote debug session in Eclipse. You do this by selecting “Run -> Debug…” from the menu. Then the following dialog appears:

Remote Debugging in Eclipse

Select the project that contains the application running on the server, enter the hostname of the server and the port you configured in the VM options and click Debug. Now set your breakpoints and debug your application.

4 Responses to “Tomcat remote debugging”

  1. tOMPSON’s blog » Blog Archive » JVM crashes with configured debug port Says:

    [...] weekend I had to experience that running a Tomcat in a JVM with debug settings configuring is not suited for productive environments. After the first instance suddenly stopped [...]

  2. Cory Says:

    Our company worked on a java/jsp/struts/tomcat web app project, and we used MyEclipseIDE. seems to work good.

  3. avinash mane Says:

    I found the blog useful and could set up accordingly.

  4. tompson Says:

    thanks for your comment - I am glad that I could help you

Leave a Reply



WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in