Sunday, April 1, 2007

AXIS client stubs deployed in Weblogic 8.1

A call to a Web service has become the nerve of web application development and this post is to discuss about one of the issues that we faced in deploying an axis generated client stub module in Weblogic 8.1.

The underlying problem is the version conflict of the javax.xml.soap.* package used by AXIS and Weblogic 8.1. Axis uses a new version of this package while the application server Weblogic 8.1 has an older version. Finally you end up with an Exception when the client program written to use the axis client stub is deployed on Weblogic.

How do you solve it?
1) Make a modification to the Weblogic startup script such that the saaj.jar of axis is ahead in the CLASSPATH (before WEBLOGIC_CLASSPATH) before webservices.jar of Weblogic.

However, this is not a suggested one as this modification would be applied for all the applications deployed in that container. A change should be application specific. Let’s go for an application specific solution.

2) Make modification to the weblogic.xml in the application such that you instruct the server to look for classes in web-inf first rather than the files on the server's classpath.

In WEB-INF\weblogic.xml

<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>

http://ws.apache.org/axis/java/install.html#WebLogic8.1

However beware of few more things when you use this solution - Your application will not have only calls to web services - Of course there be other jars. For example - Problem in parsing XML files, Weblogic server specific codes which conflicts with the jars in you web-inf (ejb client stubs and so on).

For solving the problems with parsing - makes necessary entries in the XML registry of the server to point to the new versions of the series you would have in you web-inf.

-Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
-Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl
-Djavax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl

3) Making modification to the Weblogic startup script to include the following JAVA_OPTIONS would force the server to use the Message Factory of axis. But this solution did not work for me :(

-Djavax.xml.soap.MessageFactory="org.apache.axis.soap.MessageFactoryImpl"

Try these and do add your comments if any of these solutions are not working or are not valid.

No comments: