Maven: Debugging

Here you can find information on debugging.

Step 1: Set up your IDE

First you need to setup IDE. For details, see Configure Remote Debugging in IDEA or Configure remote debugging for Eclipse.

Configure Remote Debugging in IDEA

You'll want to create a configuration for Tomcat.

  1. Select Run -> Edit Configurations
  2. Click Add New Configuration
  3. Select Remote
  4. Name the Configuration
  5. Set the Port to 8787
  6. Uncheck Make in the Before Launch section
  7. Uncheck Display settings before launching
  8. Click Apply


Configure remote debugging for Eclipse

This is as simple as creating a Remote Java Application as a Debug Configuration.

  1. Drop down the Debug button, and choose Debug Configurations.

  2. Select Remote Java Application in the Configurations list and click New Configuration.

  3. Name the configuration.
  4. Specify the project to debug (web).
  5. Specify the port (8787).

  6. Click Apply.
  7. Click Debug.

To set up a debug configuration for your unit tests, specify 5005 as the port.

Step 2: Remotely debug tomcat

  1. Make sure you have a remote configuration for Tomcat to port 8787.  Repeat the steps above for creating a remote debugger.
  2. Run this with Maven:
    mvn -Dcargo.wait=true -P int integration-test
  3. In IDEA, select the Runtime Configuration you created from the drop down in the tool bar.
  4. Run > Debug.

IDEA will connect to the Tomcat process and display the Debug view.

Maven: Debugging unit tests

Debugging unit tests is very simple with Maven and Surefire. 

All you have to do is specify the maven.surefire.debug sytem property on the command line:

mvn -Dmaven.surefire.debug test

To specify a specific test use:

mvn -Dmaven.surefire.debug -Dtest=<unqualified-classname> test