How to Debug Spring Boot Application using Intellij

We will see how to Debug the Spring Boot Application in Intellij Idea using Tomcat. While deploying the spring boot application on embedded tomcat we no need to do any configuration for remote debugging. We can run the main class in debug mode and we should be able to remote debug.

In this post, we will see how to configure debug port and debug spring boot application when we deploy spring boot application on external tomcat.

First, we will do debug configuration for Tomcat and then later will set up remote JVM configuration in Intellij. We are going to use Tomcat 8 for this tutorial.

Configure debug port in Tomcat/bin Catalina.bat

By default, Tomcat listens to 8000 ports for debugging. We are going to define some different debug port than 8000 in catalina.bat file. Go to apache-tomcat-8.5.75\bin directory and configure debug port.

In catalina.bat we can define debug port in two ways. We can use any of these.

First approach – Configure tomcat debug using CATALINA_OPTS & JPDA_OPTS

set CATALINA_OPTS=”-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n”

How to Debug Spring Boot Application using Intellij

set JPDA_OPTS=”-agentlib:jdwp=transport=dt_socket,address=9000,server=y,suspend=n”

Note – Make sure you start server using command catalina.bat jpda start

Second approach – Configure debug port using :noJuliConfig and :noJuliManager

set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"

if not "%LOGGING_MANAGER%" == "" goto noJuliManager
set LOGGING_MANAGER=-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"
Debug Spring Boot Application in Intellij using noJuliConfig

Note – To start server we can directly double click on .tomcat/bin startup.bat file.

Keep suspended value “n”. We will see what effect if we change value to “y”.

Once done with these changes save the file.

Note – We have to use either one.

Configure remote jvm debug port in intellij

  1. Configure remote java debug in intellij idea.

Click on Add Configuration

How to Debug Spring Boot Application using Intellij
Click on Add configuration

2. Click on + icon

3. Select Remote JVM Debug option and provide configuration details. Give some name for debug configuration. Also give the same port that we have configure in catalina.bat file(i.e 9000).

How to Debug Spring Boot Application using Intellij and tomcat
Debug configuration in Intellij

Click on apply and Ok.

We are good now. Once we deploy our file war file using tomcat, it should start listen our debug configure port i.e 9000.

How to verify Remote Debug in Intellij has been been successfully configured or not?

Once we start our tamcat, on console we should able to see “Listening for transport dt_socket at address: 9000

Our Tomcat should start in debug mode. Now we should be able to debug our application.

To start debugging click on debug icon. We should able to see “Connected to the target VM, address: ‘localhost:9000’, transport: ‘socket'” option as below.

We are good to debug. We should able to break point with tick mark.

Let’s do some configuration changes in catalina.bat file. Change the suspended value n to y.

set “JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=y”

Once we change the suspended value to y it will continue to listen on 9000 port until we will not click on debug icon.

Tomcat will continue to listen to 9000 until we click on debug icon

Tomcat will continue to listen to 9000 until we click on debug icon in the IntelliJ idea.

That’s all about How to Debug Spring Boot Application using Intellij and Tomcat.


Check other Tomcat and JBoss tutorials.

Spring boot Datasource configuration using tomcat
Deploy Spring boot war in JBoss EAP server.
Jboss 7 EPA Datasource configuration using oracle and spring boot.
Deploy multiple war files in JBoss to Different ports.

Spring Data JPA tutorials.

Other Spring Data JPA and Hibernate tutorials.