Apache CXF客户端错误

时间:2014-10-16 20:37:28

标签: web-services soap cxf cxf-client

我们的应用程序有一个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  

}

1 个答案:

答案 0 :(得分:0)

出于某种奇怪的原因,我在STS / eclipse中的代码指的是Java Web App Libraries。这最终成为类路径问题。

我必须说错误信息非常具有欺骗性,可以花费无数个小时来修复。