Tuesday, July 3, 2012

A complication with embedding Axis2 in a webapp

There was a need to develop a web service in our web project in order to make it interoperable with other system specially written in languages other than Java. We had number of options to choose from such as Metro which is part of GlashFish Community and Axis2 which is from The Apache Software Foundation.
We carried out a memory test. We developed a class with a method returning a byte[10000000] worth of data. Then exposing them with both Metro and Axis2. Our web service clients called the services in a loop of 100 with Thread.Sleep(1000) in between of each call. With the aid of VisualVM which offers JVM profiling and monitoring we monitored the memory usage and garbage collection. Both services were used just out of the box (without any additional configuration and tuning). They were almost the same in terms of memory usage. Annotation is the beauty of Metro. If you have your class then your are 2 steps from making your class act as a service. First annotate the class with @WebService and second annotate a method with @WebMethod. That's All. Isn't it easy!
 Here is a simple guide Building a simple Metro application you can give it a try.

With regard to ease of use, Axis2 was a bit problematic. I'm going to explain more on the problem and the approach I took to solve it.

The problem:

When my class was ready, I added axis2 Servlet to web.xml. Then,  exposing the class by adding service.xml to the folder hierarchy under WEB-INF as:
WEB-INF
     |---->services
       |---->myApp
         |---->META-INF
           |---->service.xml

 service.xml defines the the description of the service. At the final step, I tried to add all the necessary jar files to the classpath of the server. Everything seemed ok but the service was not deployed. There was no error in the logs. I checked my service by trying to checkout the WSDL on the browser. The response was an error indicating "No service is available at this URL" or "The service cannot be found for the endpoint reference (EPR) " without any further clue or any other exceptions on the server.

The solution:

 axis2-web is a "collection of JSPs that make up the Axis2 administration application "

I tried to list my service by using axis2-web at the address below by deploying the application in my Servlet engine.

http://address:port/context/services/listServices

After calling the address above I found out there is a missing class causing malfunction. Although nothing was in the log files indicating ClassNotFoundException

No comments :

Post a Comment