Debug remote Tomcat from IntelliJ

In this post we shall see how to debug remote tomcat from IntelliJ IDEA.

1. Download and Install a simple web application.

Lets download a web application for testing such as our Restful Jersey sample here, and extract the zip file containing our project. Once the project is extracted lets go the directory of the project in Terminal/DOS-Prompt and run mvn install command, this compiles the project and creates a war out of the same.

Once the above installation is completed, lets copy our project war file to our Tomcat webapps directory. The Tomcat installation on my system is

/Users/msampath/dev/apache-tomcat/webapps/

Its time to start the Tomcat in debug mode.

As we can see in the above console that we pass additional arguments while starting tomcat, the arguments jpda start tell Tomcat to start in debug mode and listen on port 8000.

2. IntelliJ IDEA Configuration

One opening IntelliJ IDEA we get the below Quick Start screen, lets select Import Project.

IntelliJ IDEA Quickstart

and in the next window lets select the extracted web application project.

IntelliJ IDEA_select_project

in the consecutive step select the project type as Eclipse and select next next.

After successful Project Import the IntelliJ IDEA Project workspace, lets add a debug point in the class EmployeeResource.java by clicking on the line we want to debug.

IntelliJ IDEA Project workspace

Now lets configure IntelliJ IDEA to listen to the Tomcat debug port by selecting the drop down and selecting Edit Configuration.

IntelliJ IDEA debug configuration

In the below screen we shall have to enter the Name for the configuration, localhost as Host or IP Address of the remote tomcat machine and the Port to 8000. Click Apply and Ok to continue.

IntelliJ IDEA debug configuration final

As a part of final step would be to start the configuration we just now created as below.

IntelliJ IDEA start debugging

If everything is well then we should see the below message in the Console.

IntelliJ IDEA success

3. Verification

Lets verify our above setup by invoking one of the RESTful services in the project, open any browser and hit the URL

http://localhost:8080/jersey-json-xml-response/employees and IntelliJ IDEA should stop control at the debug control we placed previously.

IntelliJ IDEA debug

Happy Debugging! use function keys F8 and F7 to Step Over and Step In respectively.

I hope this has been useful for you and I’d like to thank you for reading. If you like this article, please leave a helpful comment and share it with your friends.

Comments

  1. Reply

    • By manju

      Reply

Leave a Reply

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