Thursday, February 24, 2011

Problems creating SAAJ object model

Getting wsse enabled in Oracle WebLogic 10.3.x (11g) using CXF as a web service engine and Maven as a build tool proved to be a bit of a challenge. After many Google searches that came up empty, the solution included the following elements.

1) Do not package saaj-api.jar or any saaj-impl.jar with a war or ear deployed into WebLogic.

This requires a bit of work in the pom.xml files that build your project. Many of the CXF libraries have dependencies on saaj-api.jar and saaj-impl.jar so in the in all places where there is a direct or transitive dependency on a CXF library, those need to be excluded.

Example:



<dependency>
<groupid>org.apache.cxf</groupid>
<artifactid>cxf-rt-frontend-jaxws</artifactid>
<version>2.2.9</version>
<exclusions>
<exclusion>
<!-- Remove SAAJ (soap attachment) lib version that conflicts
with Weblogic Built-In version. -->
<groupid>javax.xml.soap</groupid>
<artifactid>saaj-api</artifactid>
</exclusion>
<exclusion>
<!-- Remove SAAJ (soap attachment) lib version that conflicts
with Weblogic Built-In version. -->
<groupid>com.sun.xml.messaging.saaj</groupid>
<artifactid>saaj-impl</artifactid>
</exclusion>
</exclusions>
</dependency>


2) Explicitly set the Soap MessageFactory class in a JVM startup parameter on the WebLogic container's JVM.

-Djavax.xml.soap.MessageFactory=com.sun.xml.messaging.saaj.soap.ver1_1.SOAPMessageFactory1_1Impl


REFERENCE: http://blogs.sun.com/fintanr/entry/saaj_classcast_error_with_jdkhttp://blogs.sun.com/fintanr/entry/saaj_classcast_error_with_jdk

No comments: