A Template Application for Running Axis2 in OSGi Environments
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 axis2-osgi-example.zip 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 "javax.xml.stream". 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.
From: www.dynamicjava.org
- Login or register to post comments
- 8416 reads
- Printer-friendly version
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)




Comments
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 msales@sfsu.edu? 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
Marcello
Santiago Aranda replied on Mon, 2009/03/02 - 9:11am
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()+
prueba.getAttribute2());
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(AxisFault.java:430) at com.ws20.test.MyCalStub.fromOM(MyCalStub.java:1015) at com.ws20.test.MyCalStub.getTabla(MyCalStub.java:640) at com.ws20.test.Activator.start(Activator.java:40) at org.eclipse.osgi.framework.internal.core.BundleContextImpl$2.run(BundleContextImpl.java:1009) at java.security.AccessController.doPrivileged(Native Method) at org.eclipse.osgi.framework.internal.core.BundleContextImpl.startActivator(BundleContextImpl.java:1003)
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="http://test.ws20.com">
return xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="com.ws20.test.Prueba">
attribute1>paco attribute2>chensacion
/return>
/ns:getTablaResponse>
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()
.getNamespaceURI(nsPrefix);
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
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 ;)
great,
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.
regards,
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.
regards,
Atlanta colocation
rahul roy replied on Wed, 2009/06/17 - 10:57am
rahul roy replied on Fri, 2009/06/19 - 5:39am
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.
thanks,
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