com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1I

2019-05-29 23:56发布

问题:

I have the following error:

Exception: javax.xml.soap.SOAPException: javax.xml.soap.SOAPException: Message send failed: com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to oracle.j2ee.ws.saaj.soap.MessageImpl
    at oracle.j2ee.ws.saaj.client.p2p.HttpSOAPConnection.call2(HttpSOAPConnection.java:234)
    at oracle.j2ee.ws.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:141)
    at oracle.j2ee.ws.saaj.client.p2p.HttpSOAPConnection.call(HttpSOAPConnection.java:134)

My code is:

SOAPMessage soapMessage = MessageFactory.newInstance().createMessage();

soapMessage.getSOAPPart().getEnvelope().addNamespaceDeclaration("http://action.web.nnn.some.com/", "act");

SOAPElement elemement = soapMessage.getSOAPPart().getEnvelope().getBody().addChildElement("getSomeMethod", "http://action.web.nnn.some.com/").addChildElement("arg0");

elemement.addTextNode(someDate);

soapMessage.saveChanges();

SOAPMessage responce = SOAPConnectionFactory.newInstance().createConnection().call(soapMessage, wsdlUrl);

The application running under:

  • Java(TM) SE Runtime Environment (build 1.7.0_15-b33)

  • WebLogic Server 12.1.2.0.0

The error appeared after adding the following line into setDomainEnv:

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

I am trying to switch implementation of SAAj to saaj-impl-1.3.23.jar.

My question is: how to properly ask Weblogic to use provided SAAJ implementation instead of its own?

回答1:

This question gets asked often, the answer is to tell weblogic what version it should prefer in your weblogic/application.xml document:

<wls:prefer-application-packages>
   <wls:package-name>com.sun.xml.messaging.saaj.*</wls:package-name>
</wls:prefer-application-packages>

That will force weblogic to use the saaj package in your ear APP-INF/lib directory. Check the Oracle docs here

Also see:

How to set order of jars in WebLogic?

Prevent Weblogic 12c from using system's slf4j binding

Weblogic Configuration - prefer-web-inf-classes