Search code examples
windowsdebuggingtomcatintellij-idearemote-debugging

Debug J2EE Applications on IntelliJ Community Edition and Tomcat8 (running as a service)


I've searched a lot on Remote Debugging a REST APIs written in Java using IntelliJ IDEA Community Edition.

My Setup:

Windows 10 Tomcat installed as a windows service Java 8 Intellij Community IDE

Finally after some googling and sifting through SO, found a solution that works. Posting it below.


Solution

  • Part I. Running Tomcat in Debug Mode

    When running Tomcat8 as a service

    1. Open {$TOMCAT_HOME}\bin\Tomcat8w.exe

    2. Under Java > Java Options add the following lines to enable the debug port 8001:

    -Xdebug
    -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8001
    
    1. Restart the Tomcat Service

    Part II. Attaching IntelliJ IDEA Remote Debugger

    1. Create a new Run Configuration using the Remote Template.

    2. Under Configuration > Settings Change the Port to 8001

    3. Run the new config by clicking on the debug icon and IDEA will connect to the debug port of Tomcat

    Credits:

    1. How to remotely debug the webapplication running on tomcat service?