eclipse-maven-jetty-remote-java-web-application-debugging

I have a maven based java web application running locally on the jetty server, I would like to debug the application.

Here are the steps I followed to make it happen.

  • Enable server socket address (9999) at the server side.
  • Enable Remote Java Application to bind to that address (9999).
    
    
maven_eclipse_jetty_debug

maven_eclipse_jetty_debug

1.Declare the maven-jetty-plugin on POM.xml as shown below.

<

pre style=”padding-left:60px;”>

 <!-- Jetty server plugin -->
 <plugin>
 <groupId>org.eclipse.jetty</groupId>
 <artifactId>jetty-maven-plugin</artifactId>
 <version>9.2.7.v20150116</version>
 <configuration>
 <scanIntervalSeconds>10</scanIntervalSeconds>
 <webApp>
 <contextPath>/certifier</contextPath>
 </webApp>
 </configuration>
 </plugin>
2.  click on Run As --> External Tool Configurations as shown below.
eclipse-maven-run-as-configuration

eclipse-maven-jetty-debug-run-as-external-tool-configurations

This will bring up another window as shown below. click new to create a new configuration !
external-tool-configuration

eclipse-maven-jetty-debug- external-tool-configuration

* Location: The executable file of maven , (usr/bin/mvn is for ubuntu OS.)

* Working directory: The current project working directory.

* Arguments: jetty:run 

   3. Click on Environment Tab and add a new Environment Variable as shown below.
Environment-Maven-Opts-Server-Socket-Agent

Environment-Maven-Opts-Server-Socket-Agent

MAVEN_OPTS

-Xdebug -agentlib:jdwp=transport=dt_socket,address=9999,server=y,suspend=n

Now click Apply and Run to start the jetty server, also server will be listening on port 9999 for remote debugging.

  4. Now click on Debug As --> Debug Configurations as shown below.
remote-debug-configuration

remote-debug-configuration

 5. Click on Remote Java Application and click new to create a new configurations. 
   This should bring up a new window as shown below.
remote-debug-java-application

remote-debug-java-application

Make sure to give the correct port,name, host etc. 
6. Click on the common Tab to add this configuration to the favourite menu of Debug As.
remote-debug-java-application-favourite

remote-debug-java-application-favourite

Now you should be able to debug the application by placing few breakpoints in the java source code.

 

Advertisements