This page explains how to set up remote-debugging of ServiceMix using Eclipse.
Basically, you have to perform the following steps:
- Enable remote debugging in servicemix.bat
- Specify a remote-debugging launch configuration
- 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.
- Open Run - Debug
- Mark Remote Java Application
- Create a New Launch Configuration
- Specify a name, the project you want to debug (e.g. servicemix-wsn2005) and the connection properties.
- Apply.
See http://www.onjava.com/lpt/a/6174 for details.
Performing Debugging
- Add breakpoints/debug information to the relevant code inside Eclipse.
- Start ServiceMix.
- Start debugging with the previously created launch configuration.
- Switch to debug perspective.
- Exercise the error-causing behaviour.
- Wait for Eclipse to be notified of the breakpoints.