dcp
dcp

Reputation: 55444

maven jetty debugging issue in eclipse

I am trying to debug a Maven jetty project in eclipse. I am staring jetty using "mvn clean jetty:run". Here's the complete bat file I'm using (I'm on windows).

set MAVEN_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n"  
mvn clean jetty:run

I am using the jetty-maven-plugin inside the pom file.

The bat file works ok and starts jetty without errors. Inside eclipse, I created a new debug configuration, chose "Remote Java Application" and I used 4000 for the port and localhost for the host.

When I try to run this debug configuration, I always get this error:

"Failed to connect to remote VM. Connection refused.
Connection refused: connect"

Does anyone know how I can solve this? I checked this answer, but it did not help.

Upvotes: 3

Views: 6373

Answers (2)

dcp
dcp

Reputation: 55444

The solution was that you have to change it to suspend=y instead of n in the MAVEN_OPTS. Then you do the mvn jetty:run command, and it will pause at the "Listening for transport dt_socket at address: 4000" line. After that, you run the eclipse debugger and it will attach to the process.

If you use suspend=n, it won't work (at least for me it didn't).

Upvotes: 3

Tiago Engel
Tiago Engel

Reputation: 3663

You can change your (maven_folder)/bin/mvn.bat ( or sh) and put the line you mentioned.

set MAVEN_OPTS="%MAVEN_OPTS% -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=n" 

Depending on your maven version there's a mvnDebugg file that will do this for you, in this case the debbug port will be 8000

Upvotes: 0

Related Questions