I start code execution with the typical arguments:
java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 myPackage.myMainClassname
Application starts, prints "Listening for transport dt_socket at address: 5005" and... goes further! Without any attempt to wait for connection. I CAN connect to it during execution and debugging itself works. But why does the application not wait for connection from debugger?
Looks like something is broken in my configuration, but I cannot figure out the root cause. I tried several ways to specify debug settings, different ports, run as administrator, turn off firewalls - nothing helps.
You need to specify suspend=y
if you want it to wait for connection. Your debugging is working. If you try to connect you will be able to. Most probably you are just used to using suspend=y
which blocks until the connection is established.
The behavior is expected when suspend=n
.
Select menu "Run/Edit Configurations". Check: "Edit configurations" dialog pops up. Click on "+" icon, select "Remote" from the list. Check: new configuration with name "Unnamed" appears under "Remote" category. Change configuration name to something more sensible, like "Remote Debug". Don't change any other parameters, just click "OK".
Run web-application under the debugger
Start gradle task "appStartDebug" under IntelliJ IDEA. Attention: do not try to start this task under the debugger. Run it in normal mode. Check: you should see "Listening for transport dt_socket at address: 5005" in "Run" output window. Select menu "Run/Run...", select "Remote Debug" configuration, select "Debug" command. Check: you should see "Connected to the target VM, address: 'localhost:5005', transport: 'socket'" in "Debug" output window.
Now your web-application is running under the debugger: you can set breakpoints, watch/inspect variables etc.etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With