1

I am new to IntelliJ and gradle and I want to debug my Spring boot application remotely , request is coming from UI and I need to debug the request , But not getting success , tried many thing followed JetBrain site and also tried to configure the debug setup.

but I m really getting frustrated, I guess I am not starting server in debug mode or doing something wrong.

Could anyone tell me how to set up the configuration in IntelliJ with Gradle Spring project?

enter image description here

getting error like: Unable to open debugger port (localhost:8082): java.io.IOException "handshake failed - connection prematurally closed"

enter image description here

Edit: do I need to do anything else , my app is running on 8082 port no. I am running my app normally as I do via cmd line ./gradlew bootRun

  • 1
    You need to set some JVM flags to enable debugging on the Java process. This should allow you to attach IntelliJ using the _Remote_ run configuration. Please review the following post: https://stackoverflow.com/questions/21114066/attach-intellij-idea-debugger-to-a-running-java-process – Gregor Zurowski Oct 01 '21 at 08:11
  • Please see if https://www.jetbrains.com/help/idea/tutorial-remote-debug.html help. – Egor Klepikov Oct 01 '21 at 08:46
  • Yes i have tried the same but getting error like "Unable to open debugger port (localhost:8082): java.io.IOException "handshake failed - connection prematurally closed"" – Vinay Vishwkarma Oct 01 '21 at 10:05
  • What Java version do you use? Try launching with JDK 8. Here is a related issue https://youtrack.jetbrains.com/issue/IDEA-173607 . – Egor Klepikov Oct 01 '21 at 10:17

1 Answers1

2

Unless you made some modifications to the Gradle build configuration (which I doubt being the case since you mentioned being new to Gradle), you should be able to start you application with a debugger attached to it using the --debug-jvm flag:

$ ./gradlew run --debug-jvm

and since you are using Spring Boot, you should rather use the bootRun task:

$ ./gradlew bootRun --debug-jvm

Once above command fired, your application will start and you should see below line in output:

Listening for transport dt_socket at address: 5005

stating that the JVM debugger is waiting for a client to attach on port 5005 which should be the same as your IntelliJ IDEA | Remote JVM Debug configuration port. Change the port from 8082 to 5005 for your Store_Debug configuration then click on the icon and you should see a message stating that your debugger is attached:

Connected to the target VM, address: 'localhost:5005', transport: 'socket'
tmarwen
  • 15,750
  • 5
  • 43
  • 62