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} -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:8000"

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 fcrepo
> MAVEN_OPTS="-Xmx1024m -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:8000" mvn jetty:run -pl fcrepo-webapp

IDE Debugger Profiles

Intellij

  1. Select Run > Edit Configuration
  2. Click + (Add new configuration)
  3. Select "Remote JVM Debug"
  4. Edit the Port field to 8000, to match the port you specified in the earlier steps when running jetty or tomcat.
  5. Edit the "Name" field to give it an informative name, like "Debug fedora"
  6. Click the "Debug" button to run the debugger

Then you would set break points in intellij and perform actions in Fedora.

  • No labels