15

I have created a web app using maven in eclipse. I am using jetty for running the app. I am able to run the app using the maven jetty plugin. But I am facing difficulty while debugging the app - The steps that i have followed to setup debug settings are from the below link http://www.clickonchris.com/2010/05/configuring-jetty-maven-and-eclipse-together-with-hot-deploy/

I can run the app at port 8080 and it keeps on Listening for transport dt_socket at address: 4000. For debugging i have given port 4000. But when i start the debugger in eclipse it gives me a window with following error - "Failed to connect to remote VM. Connection refused. Connection refused: connect" Can some one help me out in resolving this issue for debugging the app.

Thanks!!!

azhar_salati
  • 1,474
  • 4
  • 25
  • 51
  • Issue resolved....all the steps given in the above mentioned links are working well...i faced issues because after starting the debugger i got the error message as port 4000 was already in use... – azhar_salati Oct 24 '11 at 12:44

4 Answers4

41

Set MAVEN_OPTS using -

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

Then start jetty using -

mvn jetty:run

Start remote debugging from your fav IDE on port 8000

mtyson
  • 7,100
  • 13
  • 56
  • 97
Kapil Raju
  • 627
  • 1
  • 8
  • 10
8

Here's a quick workaround. I was battling with this problem also and after a while I achieved a lazy solution.

I use Eclipse Indigo with m2eclipse. I created a new Run Configuration: Right-Clicked the project in Project Explorer -> Run As... -> maven build. Then I defined the necessary maven commands/goals to run the project with jetty straight from Eclipse.

Finally I just ran the newly created configuration in Debug mode and got debug working. This probably messes up something else(?) but works as a quick workaround.

Antti Kolehmainen
  • 1,011
  • 1
  • 10
  • 23
3

As suggested by h3xstream in one of the comments, you can run using mvnDebug jetty:run.

Patrick
  • 1,615
  • 6
  • 18
  • 27
0

As mentioned by Pascal Thivent in this answer, since Maven 2.0.8 one can use mvnDebug in the following way:

mvnDebug jetty:run

This will start maven in debugger mode on port 8000.

aribeiro
  • 3,854
  • 4
  • 27
  • 41