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

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.
Also, no luck if I disable Real-time protection from the Microsoft Defender Antivirus.
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:
From the project:
Do you know of a way I can solve this issue or have some insights on how to debug it?

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:
I should have used the Application option. I used this configuration and now debugging works, breakpoints and all:
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.

Related

"./gradlew bootRun --debug-jvm" is not working as it should be

I am trying to debug the Spring Boot application with cmd "./gradlew bootRun --debug-jvm", earlier it was working fine but now when I am trying to build with cmd and trying to debug the code, my application is not going up. It is building without any error but still, application is not going up.
getting Listening for transport dt_socket at address: 5005 this message too.
IDK what happened , and i changed nothing in build.gradle, what can be the reason?
Debug can be turned on in different ways. Check the value of GRADLE_OPTS environment variable and org.gradle.jvmargs Java system property.
Latter can be set in different places: on the project level (in gradle.properties in project root) or in global config ~/.gradle/gradle.properties.
Setting suspend to n will allow you to both run the process in debug mode and do not wait for the debugger.
More info can be found here

Can't start Liberty server in debug mode - "agent library failed to init: jdwp"

When I try to start a WebSphere Liberty server in debug mode (to connect the Eclipse Java debugger) via:
$ ./wlp/bin/server debug MyServer
I get the following error:
Error occurred during initialization of VM
agent library failed to init: jdwp
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
and the server doesn't start.
The jvm.options contents can collide with the 'debug' subcommand
If the jvm.options file already includes options enabling the debugger then use the
liberty start <server>
subcommand rather than:
liberty debug <server>
E.g. in my case my server had file .../usr/servers/MyServer/jvm.options with contents:
#Generated by liberty-maven-plugin
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=7777
so these options collided with the options triggered by the debug subcommand.
OR
You can remove the jvm.options contents or file and use the debug subcommand instead.
NOTE: Reading this explanation, the error message becomes clear, but this Q&A is hopefully useful in case it didn't occur to someone that this is the solution.
In jvm.options put these entries:
-Dwas.debug.mode=true
-Dcom.ibm.websphere.ras.inject.at.transform=true
-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=7777
Just to add an update, jvm.options can also reside in /usr/shared so the same debug options span multiple servers. This would be a bad approach if you're running multiple servers and need to debug them all individually.

Spring STS Eclipse -noverify

Running eclipse v4.7.0
Just installed STS v3.9.0.20170706
Tried to run my spring boot app through the Spring Boot console.
I have -Xmx2g -Xms1g specified as VM arguments
Running display the following error
Invalid initial heap size: -Xms1g-noverify
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
How do I stop it from appending -noverify.
Previous to this STS plugin update never had this before
This looks like a bug that has already been fixed in the current development branch (see commit Fix fast startup vm args addition […]).
So I guess it will work again with the next update…
As a workaround in the meantime you can add something like -noverify -Ddummy= at the end of your VM Arguments, so the final command line becomes … -noverify -Ddummy=-noverify …. Or you can disable Fast startup…

ERROR: [JENKINS-18403] JDK 5 not supported to run Maven

Here is what I am doing:
Jenkins (v.1638) master runs on Windows 7
A node/slave (agent) runs on Linux (Ubuntu 14.04)
JDK 6 (Oracle jdk1.6.0_45) is used
Maven 2.2.1 is used
Next message is partially copied from console output when I kick off project build:
[webapp] $ /usr/local/jdk1.6.0_45/bin/java -cp /projects/maven-agent.jar:/projects/classworlds.jar hudson.maven.agent.Main /usr/local/apache-maven-2.2.1 /projects/slave.jar /projects/maven-interceptor.jar 58848 /projects/maven2.1-interceptor.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
ERROR: [JENKINS-18403] JDK 5 not supported to run Maven; retrying with slave Java and setting compile/test properties to point to /usr/local/jdk1.6.0_45
Established TCP socket on 59443
maven-agent.jar already up to date
classworlds.jar already up to date
maven-interceptor.jar already up to date
maven2.1-interceptor.jar already up to date
[webapp] $ /projects/jdk1.7.0_79/jre/bin/java -cp /projects/maven-agent.jar:/projects/classworlds.jar hudson.maven.agent.Main /usr/local/apache-maven-2.2.1 /projects/slave.jar /projects/maven-interceptor.jar 59443 /projects/maven2.1-interceptor.jar
<===[JENKINS REMOTING CAPACITY]===>channel started
I got confused by the output:
my Linux doesn't have JDK 5. Why does Jenkins report this error?
why are maven agent run twice? one by jdk1.6.0_45 and one by jdk1.7.0_79
jdk1.7.0_79 is configured in the field of JavaPath of Node (for running slave agent in Linux). why is it picked up to execute maven agent?
I am newbie to Jenkins and couldn't find answers to my questions.
Please explain why it works this way. I appreciate it very much for your help.
This JIRA issue should be able to help you if you read to the bottom of the page: "JDK 5 not supported with Maven" error with JDK 6

How to enable remote debugging in JBOSS 5?

How do you enable remote debugging in JBoss 5? The usual line from JBoss 4:
set JAVA_OPTS= -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n %JAVA_OPTS%
As can be found in other answers like this do not seem to work. The server never suspends. Googling "jboss 5 remote debug" doesn't bring up anything in the JBoss docs. Did something change from JBoss 4? How can I remotely debug my JBoss 5 server from eclipse?
You have suspend=n in your options. Change this to suspend=y.
Or is the line you posted not the one you're using with JBoss?
We have to do 2 changes to debug remote java application that is running in JBoss
Configure in JBoss
Creating remote debugger in in eclipse
Open run.conf.bat(windows) or run.conf(Linux) file in JBoss bin folder.
go to the below lines
`# Sample JPDA settings for remote socket debugging`
#JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=n
and remove hash in JAVA_OPTS
# Sample JPDA settings for remote socket debugging
JAVA_OPTS="$JAVA_OPTS -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y
Restart the server if it is started.
2. In Eclipse, Run -> Debug configuration -> Remote Java Application and create a new.
Note that you have to give port that is mentioned in run.conf.bat file

Resources