Setting debug configuration for maven+jetty+eclipse

32,314

Solution 1

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

Solution 2

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.

Solution 3

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

Solution 4

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.

Share:
32,314
azhar_salati
Author by

azhar_salati

I am having total 9 years of web application development experience in the following area - 2 Years of experience in Java, GWT. 3 Years of experience in Java, JSP, Servlets, Javascript. 4 Years of experience in Spring, ExtJs 4.1, ExtJs 5.0, Sencha Touch, D3 JS, Angular JS, HTML5, CSS.

Updated on January 31, 2020

Comments

  • azhar_salati
    azhar_salati over 4 years

    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!!!

  • Antti Kolehmainen
    Antti Kolehmainen over 12 years
    Whoops sorry, I realized just now it was already resolved. I should buy new glasses.
  • azhar_salati
    azhar_salati over 12 years
    hey its ok...got chance to know about your work around thanks!
  • bekt
    bekt about 9 years
    should be mvn jetty:run
  • h3xStream
    h3xStream almost 7 years
    or simply mvnDebug jetty:run