Category → axis2

Maven setup for Axis2 service development

There are many resources on the Net giving how to write an Axis2 service. And of course internals of Axis2 itself. This is a simple guide that aims to provide info on howto setup the build environment so that you can get a deployable artifact of an Axis2 service.

  1. For the most part you’ll be starting after generating Java code against a given WSDL. Generate code with the same version of Axis2 that you’ll be using to deploy this service. Evil things will happen otherwise.
  2. After this, you can create a skeleton maven project using the maven quickstart archetype.
    $ mvn archetype:generate -DgroupId=com.example.myproject -DartifactId=mysuper-service -DpackageName=org.example.myproject -Dversion=1.0-SNAPSHOT
    

    In the next screen you just have to press enter the selected archetype is the quickstart archetype. Then you can select an appropriate version number for the project followed by the package name. Now you should have a skeleton maven project where you can run mvn clean install and it’ll successfully build it.

  3. Now you can copy the generated classes to mysuper-service/src/main/java and start developing your services.
  4. To generate an Axis2 .aar file you have to tell maven to build a .aar file using the maven aar plugin.
        <build>
            <plugins>
                <plugin>
                    <groupId>org.apache.axis2</groupId>
                    <artifactId>axis2-aar-maven-plugin</artifactId>
                    <version>1.4</version>
                    <extensions>true</extensions>
                    <configuration>
                        <servicesXmlFile>${basedir}/resources/services.xml</servicesXmlFile>
                        <wsdlFile>${basedir}/resources/test.wsdl</wsdlFile>
                        <fileSets>
                            <fileSet>
                                <directory>${basedir}/lib</directory>
                                <outputDirectory>lib</outputDirectory>
                                <includes>
                                    <include>*.jar</include>
                                </includes>
                            </fileSet>
                        </fileSets>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    

    Here, I've included a lib folder as well, which contains 3rd party .jar files that's not available on a maven repo. Once you've added the lib folder containing a set of .jar files you can add the dependency later using something like,

    <dependency>
                <groupId>com.example.myjar</groupId>
                <artifactId>jarfile</artifactId>
                <version>1.0</version>
                <scope>system</scope>
                <systemPath>${basedir}/lib/the-other-awesome-project.jar</systemPath>
    </dependency>
    

    When you're specifying a 3rd party JAR dependency even though the actual JAR file might not contain a version number, you have to include something in the <version> element. Otherwise maven will not work correctly.

Now, when you type $ mvn clean install you should have a .aar file in the target folder. You can upload this to Axis2 and your services will be deployed in a few seconds.

Building within the IDE

An IntelliJ IDEA project file for your project can be easily generated with $ mvn idea:idea. But if you project use maven, you have to install IntelliJ IDEA maven 2 integration plugin. This can be done using the IDEA plugin browser. Even after adding my root pom.xml to Maven-2 Build in IDEA, I was only able to compile all the classes. I couldn't get any maven plugin goals to be executed. So, Ctrl+F9 still doesn't generate the .aar file.

As it turns out, you need to install Maven Reloaded plugin to be able to execute maven plugin goals. After installing this, the execution process dies with exit status 1 without any helpful remarks.

Axis2/C licensing

There comes a period in every year that licensing becomes an issue. Some project, somewhere on some list. The season came early for Axis2/C in the new year ;-) Dinesh list the question regarding the issue a user had.

Many free/open source apps does not bundle the dependent libraries with their tar ball mainly due the understanding that everyone could easily get the dependencies. Including them make the distribution bulky and you have to deal with gazillion of licensing issues. So it’s pretty easy to say that we use this library so please install that before installing ours.

A lot of people dislike GPL because if you even link against a GPLed library your program has to be released under the GPL as well. Luckily (for some people) FSF came up with LGPL that does not have this requirement. So, having a proprietary program linking to a LGPLed library is fine. Axis2/C does not link to a GPLed library so it can safely be released under the Apache license which BTW, can be used to develop proprietary program if that’s what you want.

I really like the idea of giving the choice to the users to do whatever they wish with a program/library and a license that does NOT restrict the freedom of the user by treating him as “users are idiots, so let’s make the software free by restricting their freedom from the license”.

Axis2/C also depends on OpenSSL for doing security stuff. Mark McLoughlin explains about the compatibility issues of the OpenSSL license with the GPL nicely. So bundling OpenSSL with Axis2/C would not only be just inconvenient, it’s a bloody pain in the arse. Since Axis2/C only links to it and since it does not contain any brain damaged clauses in it’s license there’s nothing to worry about. Also other libraries mentioned in the link pointed by Dinesh comes with licenses that allows you to build proprietary programs based on them so IMHO there’s no incompatibility issues with the Apache license which Axis2/C is released and the licenses of its dependent programs.