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
You can debug ServiceMix or any application deployed onto it using remote debugging. Remote debugging can be easily activated by using the debug parameter on the command line.
> bin/servicemix debug
or on Windows
> bin\servicemix.bat debug
Another option is to set the KARAF_DEBUG environment variable to TRUE.
This can be done using the following command on Unix systems:
On Windows, use the following command
Then, you can launch ServiceMix using the usual way:
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
This option works fine when it is needed to debug a project deployed top of Apache ServiceMix. Nervertheless, you will be blocked if you would like to debug the server ServiceMix. In this case, you can change the following parameter suspend=y in the servicemix script file:
export DEFAULT_JAVA_DEBUG_OPTS='-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
and on Windows,
set DEFAULT_JAVA_DEBUG_OPTS='-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005'
That will cause the JVM to pause just before running main() until you attach a debugger then it will resume the execution. This way you can set your breakpoints anywhere in the code and you should hit them no matter how early in the startup they are.
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; In connection properties please change port from 8000 to 5005.
See http://www.onjava.com/lpt/a/6174 for details.
Add breakpoints/debug information to the relevant code inside Eclipse.
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.