Debugging your code using Embedded Jetty in Maven

In the Using Embedded Jetty server post i blogged about how to use Embedded Jetty Server using Maven, I wanted to debug one issue in this configuration and i followed these steps to do that
  1. First start the server using mvndebug.bat jetty:run instead of using mvn.bat jetty:run. Please note that i am using Maven 3.0, if you dont have mvndebug then you can just open mvn.bat/.sh in notepad and uncommen this line and then use mvn jetty:run @REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000
    By default the Jetty server will start with suspended=y, which means the server would wait on the first line till you attach to it from Eclipse, if you dont want that you can set suspend=y
  2. Next in your Eclipse, start debug using remote attach and attach localhost port 8000 like this
  3. Next setup break points and hit the URL which would invoke the code that you want to debug and you would see that that Eclipse prompts you once the break point is hit like this

No comments: