[Jetty] Debugging With Eclipse

There are a number of options available to debug your application in Eclipse.

If not done already prepare your application for remote debugging as described here: Enable remote debugging

Via command line:

$ java -Xdebug -agentlib:jdwp=transport=dt_socket,address=9999,server=y,suspend=n -jar start.jar

 

Linking with Eclipse

Next we need to link the Eclipse project with the deployed webapp.

  1. Within Eclipse, right-click on the project containing the webapp deployed into jetty and select Debug → Debug Configurations and create a new configuration of Remote Java Application. Make sure the port you choose is the same as the one you added in Enable remote debugging.

    image

  2. Next in your webapp you can set a breakpoint within a servlet which when it is tripped will halt the remote jvm’s processing thread to await for debugging commands from your Eclipse instance.

    image

  3. Accessing that servlet within your browser, pointed at your remote debug configurated jetty-distribution, should transition your Eclipse instance to the standard Debug view.

    image

Within Eclipse

Since Jetty can be incredibly simple to embed, many people choose to create a small main method which they can launch directly within Eclipse in order to more easily debug their entire application. The best place to get started on this approach is to look through Embedding Jetty and the Embedded Examples sections.

Once you have a main method defined in order to launch your application, right-click on the source file and selectDebug As → Java Application. In your Console tab within Eclipse you should see your application startup and once it has completed startup you should be able to configure breakpoints and hit the Jetty instance as normal via your web browser.

[转] http://www.eclipse.org/jetty/documentation/9.3.x/debugging-with-eclipse.html

posted @ 2017-09-26 16:25  shareforever.999  阅读(111)  评论(0编辑  收藏  举报