Valery has posted 2 posts at DZone. View Full User Profile

A Template Application for Running Axis2 in OSGi Environments

  • submit to reddit

There is ongoing work in the Axis2 project to make Axis2 engine not only compatible with OSGi but also take all the advantages that OSGi infrastructure provides, so developers could deploy Axis2 Web Services and Modules in bundles. This article aims to provide a template application which allows launching Axis2 in an OSGi Environment within seconds. The application is runnable with Felix and Equinox in Java Environments JDK and JRE versions 1.5 and 1.6.

Archive contains the Template Application with one Web Service "Version Web Service" whose WSDL is accessible from "http://localhost:8080/services/Version?wsdl" and an Axis2 Module with two handlers which are bound to the Web Service. The application also contains a Web Admin interface which is accessible from "http://localhost:8080/system/console/list". If you would like to change the port in use (8080) then make sure to check the readme.txt file.

You can run the application by executing either the batch/script file in the "/axis2-osgi/bin" directory or by executing the following command from the "/axis2-osgi" directory:
> java -jar ./lib/da-launcher-1.0.2.jar

Key Implementation Issues

  • DA-Launcher is used to launch the application: DA-Launcher is used to launch the application as such the application can be configured easily to run with Equinox or Felix and Web Service bundles can be installed/uninstalled by simply copying/removing bundle archives in the Application Bundles directory.
  • Bundles: Axis2 and Axiom bundles are placed in the System Bundles directory "/axis2-osgi/bundles/system-bundles" and user bundles (Web Service and Module bundles) in the Application Bundles directory "/axis2-osgi/bundles/application-bundles".
  • Non-bundled libraries: I used about 12 non-bundled libraries (JAR files that has no OSGi headers) and left them for DA-Launcher to generate bundles from them. So when you run the application for the first time DA-Launcher will generate bundles from the non-bundled libraries then cache them, so next time you run the application, DA-Launcher will use the cached bundles instead of regenerating them. Non-bundled libraries are placed in "/axis2-osgi/bundles/non-bundled-libraries" directory.
  • Pax Web Service: To remove the dependency on Equinox Framework, I used Pax Web Service bundle as the Http Service for the application. The Pax Web Service bundle provides the implementation of the HTTP Service defined by OSGi Service Compendium specification and contains Servlet API and Jetty Web Server Engine classes.
  • Snapshot version of Axis2 and Axiom: Axis2 and Axiom snapshots were used since there were no releases for them.
  • Modifications to Axiom sources: The only modification to the source code of Axiom was specifying the version "1.0.0" for the imported package "". No modifications were done for the source code of Axis2.

You can deploy your own Web Services and Modules by copying the bundles that contain them to the "/axis2-osgi/bundles/application-bundles" directory.

Unfortunately, this template currently can't be run with Knopflerfish.


Published at DZone with permission of its author, Valery Abu-Eid.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)


Marcello De Sales replied on Wed, 2008/10/15 - 1:38am

Hello Valery,


Great package... I walked through it but I missed the source-code for the service implementation... Is there a way that you could provide the source-code of the Activators and the Web Service implemetation to I'm a bit familiar with Axis, but I'm new to OSGi... I'm using Knopflerfish and I was wondering why you don't have support for it...

 I'm going to be developing my research project on Web Services and OSGi and your package and explanations just helped me a lot!!!

Thansk a lot


Santiago Aranda replied on Mon, 2009/03/02 - 9:11am

I'm using your Great job!! But I have some problems I am doing some tests with the simple.version sample service and Calculator class. My new Calculator class is

public class Calculator {
public double add(double x, double y) {
return x + y;
public String hello (String nombre){
return "Hello " + nombre;
public Prueba getTabla(Prueba prueba){
System.out.println ("ENTRO EN WS GETTABLA " + prueba.getAttribute1()+
return prueba;

As you can see it is very simple. I have developed a client from generated wsdl file (myCal.wsld) using WSLD2Java. My client is invoking to add and hello methods correctly. My problem is the getTabla method. This receives a parameter from Prueba class. This class contains two attributes of type String (very simple). I can invoke to this method and the web service is receiving this call correctly. My problem is that the client can not understand the response from web service. This method returns the same parameter that it is receiving. This is the trace

Caused by: org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unsupported type null com.ws20.test.Prueba at org.apache.axis2.AxisFault.makeFault( at com.ws20.test.MyCalStub.fromOM( at com.ws20.test.MyCalStub.getTabla( at com.ws20.test.Activator.start( at org.eclipse.osgi.framework.internal.core.BundleContextImpl$ at Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(

I can not complete the cycle.
1) Client sends a Prueba object
2) Server receives Prueba object
3 )Servers sends the same Prueba object
4) Client doesn´t understand the same object that was sent itself

I am debugging my Stub class and I have found the error but I can not understand why it isn't working if I am using generated code by WSDL2Java tool. Problem is in the parse method from Prueba class. I received this message to be parsed in the client.

ns:getTablaResponse xmlns:ns="">
return xmlns:xsi="" xsi:type="com.ws20.test.Prueba">
attribute1>paco attribute2>chensacion

But this code is not working. As you can see there is a comparison between "Prueba" and type, but type is "com.ws20.test.Prueba". I mean class name + package name. This comparison is negative therefore fails in the code inside if sentence.

if (!"Prueba".equals(type)) {
//find namespace for the prefix
java.lang.String nsUri = reader.getNamespaceContext()
return (Prueba) ExtensionMapper.getTypeObject(nsUri, type, reader);

I can fix this using
if (!"com.ws20.test.Prueba".equals(type)) {
//find namespace for the prefix
java.lang.String nsUri = reader.getNamespaceContext() .getNamespaceURI(nsPrefix);
return (Prueba) ExtensionMapper.getTypeObject(nsUri, type, reader);

and that is working correctly. But I can not understand why this code can be wrong. I mean it is code from WDSL2Java, it haven´t developed by me. Maybe I need a wsdd file but I don´t know how it is possible pass it when you register Calculator as Osgi service with WSTracker.Axis2_WS property

Could you help me? I am very interested in Axis2 and Osgi. I need this kind of technology. Thanks in advanced

michael james replied on Mon, 2009/06/08 - 3:25am

Sameera, isn't the right thing to do to stub out the axis2 class loading 
stuff to be behind an interface? And then if axis2 is in an OSGi
environment, the interface would be implemented by code that loads classes
using OSGi calls instead of plain Java.


thank you,

Michael Jackson tickets

michael james replied on Mon, 2009/06/15 - 3:24am

If you mean by integrating with OSGi as the same ideas, yes, I think every project has such ideas, but the actual problem is implementing them ;)



College Videos

eugene backs replied on Mon, 2009/06/15 - 5:26am

I have created and deployed a web service on axis2. Now I start to work for client as it is given on apache axis2 site. After some effort the client gets compiled.



residential mailboxes

eugene backs replied on Mon, 2009/06/15 - 4:51pm

Currently there is ongoing work in the Axis2 project to make Axis2 engine not only compatible with OSGi but also take all the advantages that OSGi infrastructure provides so developers could deploy Web Services and Modules in bundles.



Atlanta colocation

rahul roy replied on Wed, 2009/06/17 - 10:57am

The OSGi projectizer will create everything that is needed to deploy and run the endpoint while the J2EE projectizer would create only the deployable WAR that has to be deployed into a J2EE container like Tomcat. The OSGi projectizer uses the Equinox framework as its OSGi implementation. regards, business gift baskets

rahul roy replied on Fri, 2009/06/19 - 5:39am

The starting point to achieve this is by instrumenting an OSGi implementation and providing means to monitor and manage it accordingly to business and environmental requirements. thanks, free online storage

eugene base replied on Fri, 2009/06/19 - 2:17pm

Saminda has written a comprehensive document on deploying Axis2 Web services & Axis2 modules within an OSGi container. The article describes how to deploye Axis2 services & modules within the popular Eclipse Equinox OSGi container. This is a must read for anyone intending to deploy Axis2 modules & services within an OSGi environment.



Electric Train Sets

dany rich replied on Sun, 2009/06/28 - 12:53am

i followed your instructions, but i miss the javax.servlet package. all other packages were generated without any problem, but javax.servlet isn't there and the pom.xml entry for it is missing, too.


buy concert tickets

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.