0
votes

I'm trying to debug a spring-boot application with Intellij Idea's Remote debugger.

I run my app locally on my development machine with Intellij Idea "Spring Boot" run configuration, with the following VM options configured in run configuration:

-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005

I have no other java apps running.

Then I run another Intellij Idea run configuration "Remote Debugger". It has the following config:

host: localhost; port:5005, debugger mode: Attach to remote JVM

I can see the following message in console:

Connected to the target VM, address: 'localhost:5005', transport: 'socket'.

But the breakpoints in controller classes and other components are ignored.

BUT!!! If i select my Spring Boot run configuration and simply run it in debug mode (so that there is no need for running a separate Remote Debugger run config) breakpoints work as expected.

1
@Frito, your link is dead - Sven Hakvoort
Try this ... - Frito
@Frito, Thanks but this link doesn't seem to solve my problem. Actually, I tried to do the same thing without docker, running my app locally on the host and connecting remote debugger to the VM. I get exactly the same problem as with docker. Turns out id doesn't have to do anything with docker at all. I've edited my question accordingly. - Andrey Tararaksin
Please provide some more information. What is "locally on a host"? On your developer machine or on a host but without docker? How do you configure the VM of your spring-boot application? Problems usually are: network (e.g. docker or real), configured the wrong VM for debugging, different classes in runtime VM compared to IDE or classes not compiled with debug information. - Frito
@Frito, I have replaced my original post with a description of the most simple test case, where I have no docker but still have the same problem. - Andrey Tararaksin

1 Answers

0
votes

Be sure the code is executed within the VM you are going to debug. Check this e.g. with logging.

Example:

You have to hit a REST endpoint. Doing this with your browser or a REST client will halt the VM at the configured breakpoint as expected. Doing this running a SpringBootTest will execute the code in its own VM, mocking the webserver or starting a new webserver on a different (probably arbitrary) port.