我们的应用程序有一个 CXF 服务,我们使用了以下依赖项。
compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version:'3.0.1'
compile group: 'org.apache.cxf', name: 'cxf-rt-transports-http', version:'3.0.1'
runtime group: 'org.apache.cxf', name: 'cxf-rt-bindings-soap', version:'3.0.1'
compile group: 'org.apache.cxf', name: 'cxf-rt-rs-extension-providers', version:'3.0.1'
compile 'org.apache.cxf:cxf-rt-ws-security:3.0.1'
compile 'org.apache.wss4j:wss4j-ws-security-common:2.0.1'
compile 'javax.ws.rs:jsr311-api:1.1.1'
现在我正在为不同的服务在同一个项目中编写一个客户端,但是得到了这个错误
Exception in thread "main" javax.xml.ws.WebServiceException: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:163)
at org.apache.cxf.jaxws.ServiceImpl.<init>(ServiceImpl.java:129)
at org.apache.cxf.jaxws.spi.ProviderImpl.createServiceDelegate(ProviderImpl.java:99)
at javax.xml.ws.Service.<init>(Service.java:77)
at com.inflexxion.bhcds.contract.ruleexecutionservice.RuleExecutionService.<init>(RuleExecutionService.java:46)
at com.feisystems.bham.domain.gpra.RuleExecutionWebServiceClient.main(RuleExecutionWebServiceClient.java:122)
Caused by: org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:87)
at org.apache.cxf.jaxws.ServiceImpl.initializePorts(ServiceImpl.java:218)
at org.apache.cxf.jaxws.ServiceImpl.initialize(ServiceImpl.java:161)
... 5 more
Caused by: javax.wsdl.WSDLException: WSDLException: faultCode=PARSER_ERROR: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:221)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition(WSDLManagerImpl.java:163)
at org.apache.cxf.wsdl11.WSDLServiceFactory.<init>(WSDLServiceFactory.java:85)
... 7 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:314)
at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:264)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1516)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1415)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:208)
... 9 more
当我注释掉依赖项compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version:'3.0.1'
时,它工作正常。
但是,我需要现有服务的这种依赖关系。这是依赖关系树compile group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version:'3.0.1'
+--- org.apache.cxf:cxf-rt-frontend-jaxws:3.0.1
| +--- xml-resolver:xml-resolver:1.2
| +--- asm:asm:3.3.1
| +--- org.apache.cxf:cxf-core:3.0.1
| | +--- org.codehaus.woodstox:woodstox-core-asl:4.4.0
| | | +--- javax.xml.stream:stax-api:1.0-2
| | | \--- org.codehaus.woodstox:stax2-api:3.1.4
| | \--- org.apache.ws.xmlschema:xmlschema-core:2.1.0
| +--- org.apache.cxf:cxf-rt-bindings-soap:3.0.1
| | +--- org.apache.cxf:cxf-core:3.0.1 (*)
| | +--- org.apache.cxf:cxf-rt-wsdl:3.0.1
| | | +--- org.apache.cxf:cxf-core:3.0.1 (*)
| | | +--- wsdl4j:wsdl4j:1.6.3
| | | \--- asm:asm:3.3.1
| | \--- org.apache.cxf:cxf-rt-databinding-jaxb:3.0.1
| | +--- org.apache.cxf:cxf-core:3.0.1 (*)
| | +--- org.apache.cxf:cxf-rt-wsdl:3.0.1 (*)
| | +--- com.sun.xml.bind:jaxb-impl:2.1.14
| | | +--- com.sun.xml.bind:jaxb-core:2.1.14
| | | | \--- javax.xml.bind:jaxb-api:2.1
| | | | +--- javax.xml.stream:stax-api:1.0-2
| | | | \--- javax.activation:activation:1.1 -> 1.1.1
| | | \--- com.sun.xml.fastinfoset:FastInfoset:1.2.12
| | \--- com.sun.xml.bind:jaxb-core:2.1.14 (*)
| +--- org.apache.cxf:cxf-rt-bindings-xml:3.0.1
| | \--- org.apache.cxf:cxf-core:3.0.1 (*)
| +--- org.apache.cxf:cxf-rt-frontend-simple:3.0.1
| | +--- org.apache.cxf:cxf-core:3.0.1 (*)
| | +--- org.apache.cxf:cxf-rt-bindings-soap:3.0.1 (*)
| | \--- org.apache.cxf:cxf-rt-wsdl:3.0.1 (*)
| \--- org.apache.cxf:cxf-rt-ws-addr:3.0.1
| +--- org.apache.cxf:cxf-core:3.0.1 (*)
| +--- org.apache.cxf:cxf-rt-bindings-soap:3.0.1 (*)
| \--- org.apache.cxf:cxf-rt-ws-policy:3.0.1
| +--- wsdl4j:wsdl4j:1.6.3
| +--- org.apache.cxf:cxf-core:3.0.1 (*)
| \--- org.apache.neethi:neethi:3.0.3
| \--- org.codehaus.woodstox:woodstox-core-asl:4.2.0 -> 4.4.0 (*)
我也尝试排除依赖项,但它不起作用
compile (group: 'org.apache.cxf', name: 'cxf-rt-frontend-jaxws', version:'3.0.1')
{
exclude group: 'org.apache.cxf', module: 'cxf-core' // No Problem
exclude group: 'org.apache.cxf', module: 'cxf-rt-bindings-soap' // No Problem
exclude group: 'org.apache.cxf', module: 'cxf-rt-bindings-xml' // No Problem
exclude group: 'org.apache.cxf', module: 'cxf-rt-frontend-simple' Class Not Found Error
exclude group: 'org.apache.cxf', module: 'cxf-rt-ws-addr' // No Problem
exclude group: 'org.apache.cxf', module: 'cxf-rt-transports-http' // No Problem
}