--- title: Remote-debugging ServiceMix in Eclipse --- pipeline:conf 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}}|#Enabling Remote Debugging in ServiceMix] # [Specify a remote-debugging launch configuration|#Specifying a Remote Debugging Launch Configuration] # [Start SM and switch to Debug-Perspective|#Performing Debugging] h2. 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. {noformat} > bin/servicemix debug {noformat} or on Windows {noformat} > bin\servicemix.bat debug {noformat} Another option is to set the {{KARAF_DEBUG}} environment variable to {{TRUE}}. This can be done using the following command on Unix systems: {noformat} export KARAF_DEBUG=true {noformat} On Windows, use the following command {noformat} set KARAF_DEBUG=true {noformat} Then, you can launch ServiceMix using the usual way: {noformat} bin/servicemix {noformat} or {noformat} bin\servicemix.bat {noformat} The debugging options can be modified in {{servicemix.bat}} via the {{DEFAULT_JAVA_DEBUG_OPTS}}. The default values are: {noformat} set DEFAULT_JAVA_DEBUG_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005 {noformat} 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: {noformat} export DEFAULT_JAVA_DEBUG_OPTS='-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' {noformat} and on Windows, {noformat} set DEFAULT_JAVA_DEBUG_OPTS='-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005' {noformat} 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. h2. 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. # {{Apply}}. See [http://www.onjava.com/lpt/a/6174] for details. h2. 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.