Remote Debugging

Remote debugging is very useful for tracing through the source code during the execution of the application. In order to enable remote debugging, you need to provide specific JVM options that tell the servlet container (Tomcat or Jetty) to open a port to which a debugger will attach. Additionally, you need to create a debugging profile in your IDE (Intellij or Eclipse) that specifies the host and port to which to attach the debugger.

JVM Options

Tomcat

On Ubuntu, update your /etc/defaults/tomcat7 file with:

JAVA_OPTS="${JAVA_OPTS} -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"

Restart Tomcat for the options to take effect.

Jetty (with Maven)

Using `mvn jetty:run`, you can pass in the JVM options at the command line:

> cd fcrepo4
> MAVEN_OPTS="-Xmx1024m -XX:MaxPermSize=1024m -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y" mvn jetty:run -pl fcrepo-webapp/

IDE Debugger Profiles

Intellij

  1. Select `Edit Configuration`
  2. Create `Remote` configuration
  3. Change port to match what you passed above in your JVM options
  4. Run the debugger

Eclipse

  1. Select Run -> Debug Configuration
  2. Select "Remote Java Application" -> New
    1. Change Host and Port to match your settings and select "Apply" 
       
  3. Click "Debug" to run the debugger. 
     

 

  • No labels