com.sun.xml.messaging.saaj.soap.ver1_1.Message1_1Impl cannot be cast to oracle.j2ee.ws.saaj.soap.MessageImpl

放肆的年华 提交于 2019-12-08 03:49:03

问题


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



来源:https://stackoverflow.com/questions/25553202/com-sun-xml-messaging-saaj-soap-ver1-1-message1-1impl-cannot-be-cast-to-oracle-j

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!