java 当一个 Web 服务连接到另一个 Web 服务时出现 ServiceConstructionException

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10505532/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 01:20:19  来源:igfitidea点击:

ServiceConstructionException when one web service connects to another web service

javaweb-servicesjbosswsdl

提问by sap

i have 2 web services, both work just fine when i test them with a client. but when i try to build the port to one web service from another web service JBOSS just explodes with several exceptions:

我有 2 个 Web 服务,当我用客户端测试它们时,它们都可以正常工作。但是当我尝试从另一个 Web 服务构建一个 Web 服务的端口时,JBOSS 会爆炸,但有几个例外:

Exception sending context initialized event to listener instance of class pt.ist.anacom.shared.security.SecurityInitListener: javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.

异常将上下文初始化事件发送到类 pt.ist.anacom.shared.security.SecurityInitListener 的侦听器实例:javax.xml.ws.WebServiceException:org.apache.cxf.service.factory.ServiceConstructionException:无法创建服务。

caused by

造成的

org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.

org.apache.cxf.service.factory.ServiceConstructionException:无法创建服务。

caused by

造成的

javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

javax.wsdl.WSDLException:WSDLException:faultCode=PARSER_ERROR:java.lang.ClassCastException:org.apache.xerces.parsers.XIncludeAwareParserConfiguration 无法转换为 org.apache.xerces.xni.parser.XMLParserConfiguration

caused by:

造成的:

java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration cannot be cast to org.apache.xerces.xni.parser.XMLParserConfiguration

java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration 无法转换为 org.apache.xerces.xni.parser.XMLParserConfiguration

so i have web service A and web service B. i deploy web service A and then on my contextlistener for web service B i add:

所以我有 Web 服务 A 和 Web 服务 B。我部署了 Web 服务 A,然后在我的 Web 服务 B 的上下文侦听器上添加:

org.stubs.WebServiceA_Service service = new org.stubs.WebServiceA_Service(); // EXPLODES HERE
org.stubs.WebServiceA web = service.getWebServiceAPort(); //never runs this line, crashes before

both web services are implementation first (bottom up?) meaning i define the WebService class, deploy it (JBOSS automatically generates wsdl) and then i consume it.

两个 Web 服务都是先实现(自下而上?)这意味着我定义了 WebService 类,部署它(JBOSS 自动生成 wsdl),然后我使用它。

when i access webserviceA from a test client it just works fine, but not when i try to access it from WebServiceB.

当我从测试客户端访问 webserviceA 时它工作正常,但当我尝试从 WebServiceB 访问它时就不行了。

i've lost a few days on this already and tried pretty much everything i could.. so any help is greatly appretiated.

我已经为此浪费了几天时间,并尝试了几乎所有我能做的事情..所以非常感谢任何帮助。

采纳答案by dcbyers

I experienced the same problem in multiple cases with deployment of web service to a WebLogic server with the problem being a version conflict between xerces libraries on the server classpath versus what was included with the web service instance.

在将 Web 服务部署到 WebLogic 服务器的多个案例中,我遇到了同样的问题,问题是服务器类路径上的 xerces 库与 Web 服务实例中包含的库之间存在版本冲突。

In one scenario, the solution was to avoid including the xerces library with the web service application (indicated scope 'provided' for the xerces library in the maven pom, if that happens to be your engine). In the other, the solution was to use the filtering classloader feature (of weblogic) to direct the server to use the xerces library included in the application versus the server's implementation.

在一种情况下,解决方案是避免在 Web 服务应用程序中包含 xerces 库(如果恰好是您的引擎,则在 maven pom 中为 xerces 库指明“提供”范围)。另一种解决方案是使用过滤类加载器功能(weblogic 的)来指导服务器使用应用程序中包含的 xerces 库,而不是服务器的实现。

Based on your issue, I looked around for this functionality in jboss and located this article: http://www.mastertheboss.com/jboss-application-server/223-solving-jboss-5-classloading-issues.html

根据您的问题,我在 jboss 中四处寻找此功能并找到了这篇文章:http: //www.mastertheboss.com/jboss-application-server/223-solving-jboss-5-classloading-issues.html

Hopefully this helps...

希望这有助于...