Thursday, September 22, 2011

Running / Debugging Apache Axis2 inside IntelliJ IDEA

  1. Introduction
  2. Required tools
  3. Setting up
  4. Getting the source and Building
  5. Open Axis2 source with IDEA
  6. Run/debug configuration
  7. Add required libraries
  8. Run/debug Axis2 within IDEA


Apache Axis2 is a famous web services engine and toolkit which is heavily used in industry.

2.Required Tools

Sun JDK 1.6
IntelliJ IDEA 10.5
Maven 2
Subversion 1.6

3.Setting up

Make sure you've correctly installed Sun JDK, Maven2 and SVN. (refer to my previous posts for details)

4.Getting the source and Building

Create the folder where you want to get sources.
for example, if you want it in "axis2Source"

then get the source from apache subversion repository by,

goto the modules/distribution directory and execute:

That will compile the sources and build binary and source distributions.
Goto taget directory. You will see the binary distribution pack created as axis2-1.7.0-SNAPSHOT-bin.zi.
Extract it in the same directory.

5.Open Axis2 source with IDEA

Goto IDEA.
Goto File->Open Project
Browse to the axis2Source directory

Select the parent pom and press OK. IDEA will automatically import all the modules and create the project structure.

6.Run/debug configuration

Goto Run->Edit Configurations
Add "Application" configuration using the "+" button.
Select org.apache.axis2.transport.SimpleAxis2Server as the Mail class

Set the desired log4j properties file as a VM parameter:
For example:

You have to pass axis2 repository location and axis2.xml path as program parameters.
Set the working directory as extracted bin distro root

Select the module you want to debug in "Use classpath and JDK of module" and press OK

 7.Add required libraries

Then you have to make sure all the libs required for axis2 to start are available in the classpath.
To configure that, select the desired module (axis2kernal) in project window and press F4 to open configure dialog box.
Goto dependencies tab and press Add, select Library from drop down menu.

Click "New Library..."
Select "Attatch jar directories..."

Select the lib directory of the binary distribution

Give a name such as "axis2Lib" and press OK.
You can also select other modules as dependencies if you want to debug them as well.

Finally, press OK to exit the configuration dialog.

8.Run/debug Axis2 within IDEA

Now you can Start the Axis2 server inside IDEA by the Run command (Shift+F10).
Try pointing your browser to http://localhost:8080/ and see if services get listed.

And you can debug axis2 as you debug any other code. Try setting a breakpoint in SimpleAxis2Server and start debugging (Shift+F9)

Advantage here is that, you don't have to maven build every time you change something, as opposed to remote debugging.