2014-10-16 278 views
0

我們的應用程序有一個CXF服務,爲此我們使用了以下依賴項。Apache 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 

} 

回答

0

對於一些奇怪的原因,我在STS/Eclipse代碼指的是Java的Web應用程序庫。這最終成爲一個類路徑問題。

我必須說錯誤信息是非常欺騙性的,可能需要一個無數小時才能修復。