Debugging Axis2 Web services Deployed within Tomcat
Submitted on July 17, 2008 - 21:22. Story : Level : Project : Realm :
It is often a requirement to debug Web services as they are deployed within Axis2. Once we have Axis2 deployed within a servlet container, we are able to use the debugging capabilities of those virtual machines in order to debug any Web applications deployed within them. This article by Eran Chinthaka describes debugging Web services deployed in Axis2 running on Apache Tomcat.
Table of Contents
- Table of Contents
- Introduction
- Applies To
- Starting Tomcat with Debugging Options
- Deploying Axis2 Within Apache Tomcat
- Debugging with Intellij IDEA
- Summary
- Author
Introduction
As we develop Web services, there is an extended to which we are able to debug the code on IDEs, before actually deploying these services in Web services containers. There is always the possibility for problems to stem, after deploying a Web service, that were not previously visible. These problems typically range from erroneous handling of parameters to issues related to SOAP messaging. Fortunately, there are a variety of ways to debug a Web service.
Most available Web containers of the day provides facilities to debugging them, using the capabilities of the Java Virtual Machines in which they are deployed. Sample Web services in this tutorial will be deployed inside Axis2 that runs on Apache tomcat. We will host the code inside your favorite Java development IDE, and will discuss debugging code in these settings.
Applies To
| Project/lan | Apache Axis2/Java any version |
| Tools Required | Apache Tomcat, Intellij IDEA |
| Environment | JDK 1.4 or later. (Make sure you select the correct Apache Tomcat distribution that corresponds to the JDK version you are using) |
This article first describes the process of starting Apache Tomcat in debug mode. Next, it summarizes the installation instructions for installing Apache Axis2 and move on to explain how the debugging of Web services can be carried on within IntelliJ IDEA.
Starting Tomcat with Debugging Options
Upon starting Tomcat, we need to ensure tomcat is remote debuggable. Before starting, please set CATALINA_OPTS correctly in order to inform Tomcat that we need it to start in debugging mode.
If you are on a Linux based platform, use : export CATALINA_OPTS="-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005".
If you are on Windows, set the environment variable, CATALINA_OPTS to contain "-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005"
Now you are ready start Tomcat. Go ahead and start the server. If you start Tomcat using "sh catalina.sh run" (or catalina.bat to run on windows), look carefully at the trace log the server prints. You should see tomcat printing "Listening for transport dt_socket at address: 5005" in that trace. This is confirmation that Tomcat is ready for debugging.
Deploying Axis2 Within Apache Tomcat
First follow Axis2 installation guide and deploy Axis2 inside Apache Tomcat. Make sure Axis2 works inside Tomcat. If successful, you should be able to see the Axis2 welcome page, by going to http://localhost:<YourPort>/axis2. If you didn't touch any Tomcat configuration files, you can use port 8080 as your port.
Now, create an aar file from your Web services implementation and deploy it in Axis2. There are several ways you can do this and uploading the Web service using the administration console is the easier approach. After deploying the service, you are able to confirm its successful deployment by checking your Web service under "available services" within the Axis2 admin console.
Now, let's move on to IDE specific instructions on debugging the code. This article explains how debugging can be performed within IntelliJ IDEA. A similar process can be followed to debug Web services using other available Java development IDEs.
Debugging with Intellij IDEA
Before anything else, host your Web service code inside IDEA. Make sure you set all paths and libraries to allow the code compile within the IDE. It is also important to make sure that the code you setup inside the IDE is the same code as what's hosted with Axis2. If there is a mismatch, line numbers will not match, that makes debugging a very difficult process.
1. Goto "Run" menu and select "Edit Configurations".
2. Click on "+" and select "Remote" from the menu. Check the following image.

3. Give a meaningful name in the 'mame' text box and press "OK". You should now be able to see your new configuration, under the runnable items menu.

4. Click on the debug button, to start listening in to Tomcat debug messages.
You are now all set to receive debug messages from Tomcat. Mark debugging points at proper locations you want to debug and send a SOAP message to your Web service. You should now be able to see your debug points highlighted when the execution hit those marked locations.
If you are a fan of Eclipse IDE, you can follow the instructions found here to setup your eclipse IDE to debug your Web service.
Summary
Debugging Web services can be a pain sometimes, if you don't use proper tools. In this article, we talked about using the capabilities of Java Virtual Machine, tomcat together with a java development environment to debug your web service.
Author
Author : Eran Chinthaka, Member-Apache Software Foundation. eranXchinthakaYgmail.com, where X=. and Y=@
- Login or register to post comments
- Printer friendly version
- 1912 reads










