How to debug using Maven Jetty

Debugging is a better approach to find out bugs in our programs. Here is a way to debug a maven project, and I am going to run my web application in the Jetty server.

First you need to add the following environmental variables on your Windows/Linux environment.

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

Now go to your maven web project location through command line and start the jetter server -> mvn jetty:run



Now in eclipse debug configuration, add a remote Java application instance on port 4000. Then Add some debug points to your codes  and start the remote app instance on debug mode. You can see the steps from following screen shots.





In this manner you can debug your java web apps and find out the bugs. With this way you can debug your java web app.

if you are using maven latest version( Maven 2.0.8 or later)

run the
 mvnDebug  
command instead of
 mvn 
and attach a debugger on port 8000.

Love to hear from you! feedback(comments) are always welcome 

Comments

Anonymous said…
This comment has been removed by a blog administrator.
Nice post thanks for step by step tutorial. Jetty is great you don't need a separate web server.

Popular posts from this blog

XSLT - Modify Date and DateTime value

Integrate With Mutual Certificate Authentication based Service

Yield Price Sri Lanka - Android Application