问题
I am stuck with the following error when I deploy my web-services client application in weblogic. [This application has been working without any issues in tomcat.]
Cannot resolve reference to bean 'saajSoapMessageFactory' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'saajSoapMessageFactory' defined in class path resource [.../core/ws/ws-config.xml]: Invocation of init method failed; nested exception is org.springframework.ws.soap.SoapMessageCreationException: Could not create SAAJ MessageFactory: Unable to create message factory for SOAP: weblogic.webservice.core.soap.MessageFactoryImpl cannot be cast to javax.xml.soap.MessageFactory; nested exception is javax.xml.soap.SOAPException: Unable to create message factory for SOAP: weblogic.webservice.core.soap.MessageFactoryImpl cannot be cast to javax.xml.soap.MessageFactory
Here is the bean definition in ws-config.xml
(bean id="saajSoapMessageFactory" class="org.springframework.ws.soap.saaj.SaajSoapMessageFactory")
I tried searching for this issue, but unfortunately could not find any solution. Am I missing anything in the spring config? Has any one faced this issue before?
回答1:
I've not come across this - but what's happening is that Weblogic uses it's own default for the MessageFactoryImpl
Check your weblogic startup logs and you will see some parameters set such as
javax.xml.rpc.ServiceFactory = weblogic.webservice.core.rpc.ServiceFactoryImpl
javax.xml.soap.MessageFactory = weblogic.webservice.core.soap.MessageFactoryImpl
You can try 2 options (I dont know which will work, try it out)
A)
In your client, set these yourself to the Spring equivalents
System.setProperty("javax.xml.soap.MessageFactory", "org.springframework.ws.soap.saaj.SaajSoapMessageFactory");
System.setProperty( "javax.xml.rpc.ServiceFactory", "** Spring version **");
B) Pass your required version as a -D
parameter in the startWeblogic.cmd
-Djavax.xml.soap.MessageFactory=org.springframework.ws.soap.saaj.SaajSoapMessageFactory
and add saaj jars to the weblogic classpath.
来源:https://stackoverflow.com/questions/8210702/weblogic-webservice-core-soap-messagefactoryimpl-cannot-be-cast-to-javax-xml-soa