Unable to start the daemon process when debugging in IntelliJ on WSL

Viewed 30

I am trying to debug a Gradle Tomcat embedded project on IntelliJ using Windows Subsystem for Linux (WSL).

The project runs correctly using the terminal with gradle run, and also runs with no issues when using the run button on IntelliJ; however, it always fails when I try to debug it. It always shows this message:

Running Gradle on WSL...
> Task :wrapper UP-TO-DATE

BUILD SUCCESSFUL in 679ms
1 actionable task: 1 up-to-date
Running Gradle on WSL...

And then it fails with this message:

Unable to start the daemon process.
This problem might be caused by incorrect configuration of the daemon.
For example, an unrecognized jvm option is used.
Please refer to the User Manual chapter on the daemon at https://docs.gradle.org/7.5/userguide/gradle_daemon.html
Process command line: /home/user/.sdkman/candidates/java/18.0.1.1-open/bin/java -XX:MaxMetaspaceSize=256m -XX:+HeapDumpOnOutOfMemoryError -agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=192.168.1.74:60140 --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.lang.invoke=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.prefs/java.util.prefs=ALL-UNNAMED --add-opens java.base/java.nio.charset=ALL-UNNAMED --add-opens java.base/java.net=ALL-UNNAMED --add-opens java.base/java.util.concurrent.atomic=ALL-UNNAMED -Xms256m -Xmx512m -Dfile.encoding=windows-1252 -Duser.country -Duser.language=en -Duser.variant -cp /home/daniel-personal/.gradle/wrapper/dists/gradle-7.5-bin/f1w0cc9nuo0eivz97x2xlu9sv/gradle-7.5/lib/gradle-launcher-7.5.jar org.gradle.launcher.daemon.bootstrap.GradleDaemon 7.5
Please read the following process output to find out more:
-----------------------
ERROR: transport error 202: connect failed: Connection timed out
ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
JDWP exit error AGENT_ERROR_TRANSPORT_INIT(197): No transports initialized [open/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c:734]

I found a thread mentioning that this could be related with firewall configurations. I tried disabling Windows Defender Firewall, but the same issue prevails.

enter image description here

Also, no luck if I disable Real-time protection from the Microsoft Defender Antivirus.

enter image description here

I also tried to disable both at the same time with no luck.

I am using:

  • Windows 11 Pro - 10.0.22000 Build 22000
  • WSL - Version 2
  • Ubuntu - Ubuntu 20.04.4 LTS
  • IntelliJ Idea - 2022.2.1

My configurations on Intellij:

  • From settings: enter image description here
  • From the project: enter image description here

Do you know of a way I can solve this issue or have some insights on how to debug it?

1 Answers

I found the issue. I was trying to run the project using the wrong Run/Debug Configuration. I hope this helps someone in the future.

I was using the Gradle option like so:

enter image description here

I should have used the Application option. I used this configuration and now debugging works, breakpoints and all:

enter image description here

The working directory is the root of the repository.

This option selects by default the project name. I switched it to the .main option and then it worked.

enter image description here

Related