Friday, December 12, 2008

Getting Started With Axis2/Java

Last week, I was involved with some work in Axis2.  I had to set up Axis2. So I decided to write down the steps incase someone who is going to build axis2 from source and setup a development environment to make some modification to axis2.

Step1. Install maven2

You need to  install Apache Maven 2. Axis2 and many other dependent projects of Axis2 uses maven2 as the build system. Download mavan2 from Apache maven  site.

I used the zip archive of maven. Once you have download, just extract the zip archive a preferred location. For example, my maven2 directory is E:\javasoftware\apache-maven-2.0.9.

image

When extracted, you will find an xml file named settings.xml in the conf directory. You can edit this file and set configurations according to your preferences. One of the important settings in this file is the maven repository location. Maven repository is a directory when, maven downloads and keeps dependency jar files for building a project. Also the mvn install command will copy the built jar file to this repository at the end of a build process as well.  So I configured the repository to location

E:\java\respository.

<localRepository>E:\javasoftware\repository</localRepository>

There are other details like configuring a proxy. You can find a detailed guide here. 

Create an environment variable MAVEN_HOME and set the maven directory as its value.

image

Now add the bin directory to your PATH environment variable.  You can directly add the maven bin directory to path and it will work without the MAVEN_HOME. However, it is always preferable to use an separate  environment variable for ease in conformability.

 image

Now you have configured maven. Open a new command prompt and type mvn -v to verify whether maven is installed properly.Congratulations, you have successfully configured maven on your system.

Step2. Checkout Axis2 and  build using maven2.

You need to have an svn client installed on your machine in order to checkout source code from the svn server. Assuming that you have an svn client.

Checkout Apache Axis2 from https://svn.apache.org/repos/asf/webservices/axis2/trunk/java

checkout

It will take a few minutes to complete the checkout since, axis2 has large amount of source files.  Once you have taken the checkout, open a command prompt, go to axis2 checkout directory, and type mvn clean install to build the axis2 snapshot.

image

It will take some time to download the dependency jars, compile source and run the tests. Since you are building it for the first time, It is better to run the tests as well. In case you want to skip the Unit tests which will consume time, use the option -Dmaven.test.skip

Once the build is completed, the resulting axis2-SNAPSHOT.jar file will be copied to the folder "org\apache\axis2\axis2\SNAPSHOT" within your maven repository.

Use command mvn -e -X install -Dmaven.test.skip=true -Drelease   to build the distribution. This will include

axis2-SNAPSHOT-war.zip
axis2-SNAPSHOT-src.zip
axis2-SNAPSHOT-bin.zip

You can find some useful maven targets for axis2 here.

Step3. Build the project file for IDEA\Eclipse and configure the project

Use the command mvn idea:idea to build the IntelliJ IDEA project file for axis2. Once this command complete's you will find the axis2.jpr project file in the outer most directory.

image

If you prefer using eclipse editor, use mvn eclipse:eclipse to build the eclipse project files.

image

Now double click on the axis2.jpr and open axis2 project in idea IDE. I will go through the steps in configuring the project in IDEA and how to debug ect in my next blog post.

2 comments:

  1. you have a nice site.thanks for sharing this site. various kinds of ebooks are available here

    http://feboook.blogspot.com

    ReplyDelete
  2. I am working with axis2 and spring i am in need of axis2-spring-SNAPSHOT.jar.Could i get it somewhere or else should i create it? please let me know via your blog.

    ReplyDelete