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”
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
:noJuliConfig
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
:noJuliManager
set "JAVA_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,address=9000,server=y,suspend=n"
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
- Configure remote java debug in intellij idea.
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).
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 in the IntelliJ idea.
That’s all about How to Debug Spring Boot Application using Intellij and Tomcat.
References
https://docs.oracle.com/cd/E13224_01/wlw/docs103/guide/ideuserguide/servers/conTomcat.html
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.
- Spring Data findById() Vs getOne()
- Spring Data JPA CrudRepository findById()
- Spring Data JPA JpaRepository getOne()
- Spring Data CrudRepository saveAll() and findAll().
- Spring Data CrudRepository existsById()
- Spring Data JPA delete() vs deleteInBatch()
- Spring Data JPA deleteAll() Vs deleteAllInBatch()
- Spring Data JPA JpaRepository deleteAllInBatch()
- Spring Data JPA deleteInBatch() Example
- Spring Data JPA JpaRepository saveAndFlush() Example
- Spring Data JPA CrudRepository count() Example
- Spring Data JPA CrudRepository delete() and deleteAll()
- Spring Data JPA CrudRepository deleteById() Example
- CrudRepository findAllById() Example Using Spring Boot
- Spring Data CrudRepository save() Method.
- Sorting in Spring Data JPA using Spring Boot.
- Spring Data JPA example using spring boot.
- Spring Data JPA and its benefit.
Other Spring Data JPA and Hibernate tutorials.
- @Version Annotation Example In Hibernate.
- Hibernate Validator Constraints Example Using Spring Boot.
- @Temporal Annotation Example In Hibernate/Jpa Using Spring Boot.
- Hibernate Table Per Concrete Class Spring Boot.
- Hibernate Table Per Subclass Inheritance Spring Boot.
- Hibernate Single Table Inheritance using Spring Boot.
- One To One Mapping Annotation Example in Hibernate/JPA using Spring Boot and Oracle.
- One To One Bidirectional Mapping Example In Hibernate/JPA Using Spring Boot and Oracle.
- One To Many Mapping Annotation Example In Hibernate/JPA Using Spring Boot And Oracle.
- Many To One Unidirectional Mapping In Hibernate/JPA Annotation Example Using Spring Boot and Oracle.
- One To Many Bidirectional Mapping In Hibernate/JPA Annotation Example Using Spring Boot and Oracle.
- Many To Many Mapping Annotation Example In Hibernate/JPA Using Spring Boot And