Spring webservicetemplate jar conflict issue with Axis2

心已入冬 提交于 2019-12-11 15:24:35

问题


I use Spring web services and Axis2 both in my app. They are completely independent and it works great, except that Spring WebServiceTemplate started throwing the exception below..

I suspect it's happening because Spring requires saaj.jar (which has javax.xml.soap.SOAPElement) and Axis2 requires axiom-dom.jar (which has org.apache.axiom.om.impl.dom.ElementImpl)

Both the interfaces extend org.w3c.dom.Element and somehow Spring in picking up the one from axiom-dom.jar

Any ideas as to what i can do to prevent Spring from picking up the wrong implementation at runtime other than perhaps renaming axiom-dom.jar to z-axiom-dom.jar, so its later in the classpath?

com.sun.xml.wss.XWSSecurityException: com.sun.xml.wss.XWSSecurityException: java.lang.ClassCastException: org.apache.axiom.om.impl.dom.ElementImpl cannot be cast to javax.xml.soap.SOAPElement at org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor.secureMessage(XwsSecurityInterceptor.java:139) at org.springframework.ws.soap.security.AbstractWsSecurityInterceptor.handleRequest(AbstractWsSecurityInterceptor.java:179) at org.springframework.ws.client.core.WebServiceTemplate.doSendAndReceive(WebServiceTemplate.java:542) at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:502) at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:351) at org.springframework.ws.client.core.WebServiceTemplate.marshalSendAndReceive(WebServiceTemplate.java:341)


回答1:


This is not a conflict between saaj and axiom-dom, but a conflict between saaj and axis2-saaj.jar. axis2-saaj uses axiom-dom which is why the exception refers to Axiom. If you don't use the JAX-WS implementation provided by Axis2, then you don't need axis2-saaj, so depending on your use case, removing it may be a solution.



来源:https://stackoverflow.com/questions/12944811/spring-webservicetemplate-jar-conflict-issue-with-axis2

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