Sunday, September 4, 2011

Remote Debugging Apache ODE with Apache Tomcat Server in IntelliJ Idea

Apache ODE (Orchestration Director Engine) can be deployed and run in three different environments. One of them is deploying ODE as a web service in Axis 2, by deploying the ode war distribution inside an application server like Apache tomcat. Once it is deployed and started you may need to debug ODE, to understand what is going inside the engine. The following is a short guide on how to debug Apache ODE with tomcat in both Windows and Linux environments.
If you don't know how to deploy ODE and run with Apache tomcat first visit and read the this previous blog post.

Applicable with:

Apache Tomcat : 7.0.11    Download 

Apache ODE: 1.3.5           Download

Debug ODE in Ubuntu 10.04

Apache Tomcat can be debugged with JPDA debugger by starting tomcat with catalina script. To do this start go to Tomcat_Home/bin folder and enter the following command.

apache-tomcat-7/bin$ sh jpda run  

This will start catalina server in debug mode and you can see it displays the message, "Listening for transport dt_socket at address: 8000" in terminal as shown in Figure 1.

Figure 1: Starting tomcat in debug mode

Another method would be setting the JAVA_OPTS to start up java for listening to debugger connections by giving,
apache-tomcat-7/bin$  export JAVA_OPTS=
"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

When it is set start the catalina server in the usual manner as 'sh  run' and tomcat will be started in debug mode.   

Now we can create a remote debug configuration by giving Host: localhost and Port: 8000 in our IDE which we have used to open the ode source code, and debug ODE by using that. Remember to use the same port used as JPDA_ADDRESS in tomcat as your IDE's remote debug port. The default port address is 8000.
Creating a Remote Debug Configuration in Idea 10.0.3
This is how to create a remote debug with IntelliJ Idea 10.
  • Go to Run --> Edit Configurations in the IDE
Figure 2: Creating a Remote Debug Configuration

  • When it is selected the Run/Debug Configuration window will pop up.  Click the  icon there and select 'remote' from 'Add New configuration' menu.

Figure 3: Created New Remote Debug
  • This will create a new remote debug configuration for us. Let's name it as 'ode' and fill the Host field with 'localhost' and Port field with '8000'. Then click OK.
Figure 4: Setting up Host and Port for remote debugging
  • The new remote debug is successfully created now. After the tomcat server is started, select 'ode' remote debug and start it by clicking icon in Idea. It will connect to the server via the defined port and you can start debug ODE now.

Figure 5: Debugging ODE

Note: port 8000 is the default port address used in tomcat for JPDA debugging, however if port 8000 is busy(due to some other application running there), you can change it into another port. 
  • Open script in the Tomcat_Home/bin folder and search for JPDA_ADDRESS, you will see JPDA_ADDRESS="8000" defined there. Change it to any available port and restart tomcat under JPDA debugger. The server will listen from the new address now.
Figure 6: Edit the JPDA_PORT in catalina script

         You can also change this port (let's say to 8010) by giving,

         apache-tomcat-7/bin$ export JPDA_ADDRESS=8010 in terminal.

  • Now go back to the 'ode' remote debug and select 'Edit Configurations' to edit its configurations.

Figure 7: Edit the remote debug configuration in Idea 10.0.3

  • When Debug Configuration window appears set the Port address into the modified port,8010. Once it is set ODE can be debugged using the new port again.

Debug ODE in Windows
Debugging in Windows is also very similar to in Linux, except the commands that should be used. All the following demonstrations are performed in Windows 7 version.

  • To start tomcat, go to the tomcat home's bin folder and start catalina.bat file under jpda debugger as follows.

C:\Apache-Tomcat-7\bin> catalina.bat jpda start

Now catalina will start in remote debugging mode under JPDA debugger using its default port 8000. When it is started you will see tomcat starts a new debug console as shown below in Figure 8.
Figure 8: tomcat Debugger Console in Windows 

This can be also done by setting an environment variable  JAVA_OPTS, and starting the tomcat server with usual command.

C:\ Apache-Tomcat-7\bin>  set JAVA_OPTS=
"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000"

C:\Apache-Tomcat-7\bin> catalina.bat run

When it is started create a new remote debug configuration as described in the previous section by configuring the correct Port address and Host. Once the remote debug configuration is connected to the server, you can debug ODE successfully.

Note: To change the port address from 8000 to another port 'set' command can be used in Windows. Go to Apache-Tomcat-7\bin and enter;

C:\ Apache-Tomcat-7\bin> set JPDA_ADDRESS="8010"

Figure 9: Change JPDA_ADDRESS in tomcat

When tomcat is started again you will see that it has changed the listening port into '8010' as we changed. Change the Port address in the remote debug into this new address and start debugging again. 
Figure 10: Debugging tomcat in Different Port
JPDA_ADDRESS can be also changed from the catalina.bat file in Windows. Right click catalina.bat file and select 'Edit' option from the menu. Then the file will be opened using Notepad or some other text document opening application in Windows. Search for JPDA_ADDRESS and change its value into a new one. Save the file back and start tomcat again.


  1. Hi

    I am trying to debug ODE and I followed your steps for tomcat5.5 and IDEA 10.0.3, but its giving me this error

    Error running ode: Unable to open debugger port : "Connection refused: connect"

    I was working with the default 8000 JPDA debugger but then i changed it to 9090 in catalina.bat and remote debug configurations in IDEA and its still the same error. The server output is showing me this

    19:53:27,314 WARN [ODEAxisOperationDispatcher] No operation has been found!
    19:53:27,338 ERROR [AxisEngine] The endpoint reference (EPR) for the Operation not found is /ode/processes/helloWorld and the WSA Action = null
    org.apache.axis2.AxisFault: The endpoint reference (EPR) for the Operation not found is /ode/processes/helloWorld and the WSA Action = null
    at org.apache.axis2.engine.DispatchPhase.checkPostConditions(
    at org.apache.axis2.engine.Phase.invoke(
    at org.apache.axis2.engine.AxisEngine.invoke(
    at org.apache.axis2.engine.AxisEngine.receive(
    at org.apache.axis2.transport.http.util.RESTUtil.invokeAxisEngine(
    at org.apache.axis2.transport.http.util.RESTUtil.processURLRequest(
    at org.apache.axis2.transport.http.AxisServlet$RestRequestProcessor.processURLRequest(
    at org.apache.axis2.transport.http.AxisServlet.doGet(
    at org.apache.ode.axis2.hooks.ODEAxisServlet.doGet(
    at javax.servlet.http.HttpServlet.service(
    at javax.servlet.http.HttpServlet.service(
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(
    at org.apache.catalina.core.StandardWrapperValve.invoke(
    at org.apache.catalina.core.StandardContextValve.invoke(
    at org.apache.catalina.core.StandardHostValve.invoke(
    at org.apache.catalina.valves.ErrorReportValve.invoke(
    at org.apache.catalina.core.StandardEngineValve.invoke(
    at org.apache.catalina.connector.CoyoteAdapter.service(
    at org.apache.coyote.http11.Http11AprProcessor.process(
    at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(

    can you please help me!!

  2. Hi,
    As your first question,
    "Error running ode: Unable to open debugger port : "Connection refused: connect" message usually occurs when you haven't started your tomcat server before debugging it with Idea. Make sure you have started tomcat in debug mode first and then start the remote debug.Can you check what is the console output when you gives the 'catalina.bat jpda start' command?

    About the second part i think you got this error log when trying to run the sample HelloWorld process. In that case you need to call the operation which is rendered in your HelloWorld Service when running the process from your web browser. Therefore your input URL in the browser should be like this.

    Try this in your browser after starting ODE and you will see the response.
    The following thread has a good explanation on this.

  3. Hi Ishara,
    thanks you very very much for your step by step explanation. It worked really well following your steps.
    Now you have a new fan from Frankfurt/Germany :-)

  4. I got this error when I am running. How to fix it?
    ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
    Error occurred during initialization of VM
    agent library failed to init: jdwp