This page explains how to set up remote-debugging of ServiceMix using Eclipse.

Basically, you have to perform the following steps:

  1. Enable remote debugging in servicemix.bat
  2. Specify a remote-debugging launch configuration
  3. Start SM and switch to Debug-Perspective

Enable remote debugging in ServiceMix

The following section in servicemix.bat is the one that matters:

if "%SERVICEMIX_DEBUG%" == "" goto :SERVICEMIX_DEBUG_END
    rem Use the defaults if JAVA_DEBUG_OPTS was not set
    if "%JAVA_DEBUG_OPTS%" == "" set JAVA_DEBUG_OPTS=%DEFAULT_JAVA_DEBUG_OPTS%
    
    set "JAVA_OPTS=%JAVA_DEBUG_OPTS% %JAVA_OPTS%"
    call :warn Enabling Java debug options: %JAVA_DEBUG_OPTS%
:SERVICEMIX_DEBUG_END

In order to activate it, you need to set the environment variable SERVICEMIX_DEBUG.

For instance in Windows:

SET SERVICEMIX_DEBUG=TRUE

Or in Linux:

export SERVICEMIX_DEBUG=TRUE

ServiceMix runs in debugging mode if you can see the following output when running it:

...
servicemix.bat: Enabling Java debug options: -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005
...

The debugging options can be modified in servicemix.bat via the DEFAULT_JAVA_DEBUG_OPTS. The default values are:

set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005

Specifying a Remote Debugging Launch Configuration

Specify an Eclipse Remote Java Application debug launch configuration on the project you want to monitor.

  1. Open Run - Debug
  2. Mark Remote Java Application
  3. Create a New Launch Configuration
  4. Specify a name, the project you want to debug (e.g. servicemix-wsn2005) and the connection properties.
  5. Apply.

See http://www.onjava.com/lpt/a/6174 for details.

Performing Debugging

  1. Add breakpoints/debug information to the relevant code inside Eclipse.
  2. Start ServiceMix.
  3. Start debugging with the previously created launch configuration.
  4. Switch to debug perspective.
  5. Exercise the error-causing behaviour.
  6. Wait for Eclipse to be notified of the breakpoints.