Apache CXF 噩梦
我有一个基于 Spring 框架的应用程序,我们之前已成功部署该应用程序,并且正在添加新功能。我们的开发机器是JDK6和Tomcat7。我们使用的是Spring 3.1.0.M2。旧代码使用 Apache CXF 2.4.1 提供 Web 服务并部署到我们的测试服务器 Tomcat 5.0 和 JDK5 上。
作为新功能的一部分,我做了这个 Spring Web 服务客户端定义来访问外部服务
<bean id="urlWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="au.com.company.app.client.urlservice.UrlWebService" />
<property name="wsdlDocumentUrl" value="http://dev.urlservice-int.services.company.com.au/v1_0/shortener?wsdl" />
<property name="namespaceUri" value="http://urlservice.services.company.com.au/shortener" />
<property name="serviceName" value="GenerateShortenedUrlWebServiceImplService" />
<property name="portName" value="generateShortenedUrlWebServicePort" />
</bean>
但是现在,当我尝试部署到测试服务器上时,我得到:
Caused by: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;
at org.apache.cxf.staxutils.StaxUtils.addLocation(StaxUtils.java:1083)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:971)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:947)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:874)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:226)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Service.java:56)
at javax.xml.ws.Service.create(Service.java:697)
at org.springframework.remoting.jaxws.LocalJaxWsServiceFactory.createJaxWsService(LocalJaxWsServiceFactory.java:125)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.prepare(JaxWsPortClientInterceptor.java:334)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.afterPropertiesSet(JaxWsPortClientInterceptor.java:316)
at org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean.afterPropertiesSet(JaxWsPortProxyFactoryBean.java:42)
我已经这样做了两天,并且已经尝试了我可以谷歌搜索的所有内容并想到。 Tomcat 5.0 似乎在其认可目录中安装了旧版本的 Xerces,并且 CXF 似乎正在尝试使用。
现实情况是,我根本不希望 CXF 参与此 Spring 客户端代码。它之所以存在只是因为我无法删除遗留代码。我一直无法找出让 CXF 忽略该客户端的方法。我无法升级服务器和 JDK,也无法删除旧的 Xerces。我尝试包含更高版本的 Xerces 以及各种其他 XML API,希望 CXF 能够开始使用其中之一而不是 Xerces,并且我已经尝试了我能找到的任何配置类型更改。但到目前为止没有任何效果。
有谁知道如何 (a) 阻止 CXF 将其挂钩到这个 bean 中?或者 (b) 告诉 CXF 至少不要使用过时的 Xerces?
I have a Spring Framework based application which we have previous deployed successfully and are adding new functionality. Our dev machines are JDK6 and Tomcat7. We are using Spring 3.1.0.M2. The old code uses Apache CXF 2.4.1 to provide web services and deploys onto our test severs which are Tomcat 5.0 and JDK5.
As part of the new functionality I did this spring web service client definition to access an external service
<bean id="urlWebService" class="org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean">
<property name="serviceInterface" value="au.com.company.app.client.urlservice.UrlWebService" />
<property name="wsdlDocumentUrl" value="http://dev.urlservice-int.services.company.com.au/v1_0/shortener?wsdl" />
<property name="namespaceUri" value="http://urlservice.services.company.com.au/shortener" />
<property name="serviceName" value="GenerateShortenedUrlWebServiceImplService" />
<property name="portName" value="generateShortenedUrlWebServicePort" />
</bean>
But now when I try and deploy onto the test server I get:
Caused by: java.lang.AbstractMethodError: org.apache.xerces.dom.ElementNSImpl.setUserData(Ljava/lang/String;Ljava/lang/Object;Lorg/w3c/dom/UserDataHandler;)Ljava/lang/Object;
at org.apache.cxf.staxutils.StaxUtils.addLocation(StaxUtils.java:1083)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:971)
at org.apache.cxf.staxutils.StaxUtils.readDocElements(StaxUtils.java:947)
at org.apache.cxf.staxutils.StaxUtils.read(StaxUtils.java:874)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:226)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:186)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:92)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:203)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:147)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:90)
at javax.xml.ws.Service.<init>(Service.java:56)
at javax.xml.ws.Service.create(Service.java:697)
at org.springframework.remoting.jaxws.LocalJaxWsServiceFactory.createJaxWsService(LocalJaxWsServiceFactory.java:125)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.prepare(JaxWsPortClientInterceptor.java:334)
at org.springframework.remoting.jaxws.JaxWsPortClientInterceptor.afterPropertiesSet(JaxWsPortClientInterceptor.java:316)
at org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean.afterPropertiesSet(JaxWsPortProxyFactoryBean.java:42)
I've been on this for two days now and have tried everything I can google and think of. The Tomcat 5.0 appears to have had an old version of Xerces installed in it's endoresed directories and CXF appears to be attempting to use.
Reality is that I don't want CXF involved at all with this spring client code. It's only there because of legacy code I cannot remove. I've not been able to figure out anyway way to get CXF to ignore this client. I cannot upgrade the server and JDK, or remove the old Xerces. I've attempted to include a later version of Xerces, and a wide range of other XML APIs in the hope that CXF will starting using one of them instead of Xerces, and I've tried any config type changes I can find. but so far nothing works.
Does anyone have any idea how to (a) stop CXF from getting it's hooks into this bean? or (b) tell CXF to at least not use the out of date Xerces?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您已通过 Tomcat 层次结构中旧的 Xerces 副本将该版本的 Xerces 强行放入 CXF 中。您需要升级 tomcat 中的 Xerces——这就是“认可”的工作原理。
在 Java 1.5 中,您无法避免将 CXF 用于 Web 服务客户端。没有内置的 JAX-WS 替代方案。如果您运行的是 1.6,则可以使用内置提供程序。
You've forced that version of Xerces down CXF's throat via that old copy of Xerces in the Tomcat hierarchy. You need to upgrade the Xerces in tomcat -- that is how 'endorsed' works.
You cannot avoid using CXF for the web service client in Java 1.5. There's no built-in JAX-WS alternative. If you were running in 1.6, you could use the built-in provider instead.
尝试使用 TomEE 1.5.2 作为您的 tomcat 服务器,而不是 tomcat 7.0.39,TomEE 设置为包含库中的所有 jar 以及您需要的一切。
Try using TomEE 1.5.2 for your tomcat server instead of tomcat 7.0.39, TomEE is setup to have all the jars in the lib and everything you need.