cxf调用webservice时报错汇总

本文解决Apache CXF在创建SOAP Web服务时遇到的多种异常情况,包括JAXBUtils和WSDLServiceFactory引发的问题,并提供了必要的依赖库来确保服务正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1.
报org.apache.cxf.common.jaxb.JAXBUtils或空指针错误或
Exception in thread “main” java.lang.IllegalStateException: Unable to create schema compiler
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:728)
Caused by: javax.xml.bind.JAXBException
- with linked exception:
[java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC]
at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:713)

注意C:\Program Files\Java\jre7\lib目录下有没有tools.jar

还可能是
这里写图片描述

2.
Exception in thread “main”
org.apache.cxf.service.factory.ServiceConstructionException: Failed to create service.
at org.apache.cxf.wsdl11.WSDLServiceFactory.(WSDLServiceFactory.java:76)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:296)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:276)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:269)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:204)
at zxgz.src.main.java.com.idress.zxgz.webservice.test.sendBaseXMLEsbWebService(test.java:38)
at zxgz.src.main.java.com.idress.zxgz.webservice.test.main(test.java:16)
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.(WSDLServiceFactory.java:74)
… 6 more
Caused by: java.lang.RuntimeException: Cannot create a secure XMLInputFactory
at org.apache.cxf.staxutils.StaxUtils.createXMLInputFactory(StaxUtils.java:323)
at org.apache.cxf.staxutils.StaxUtils.getXMLInputFactory(StaxUtils.java:273)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1782)
at org.apache.cxf.staxutils.StaxUtils.createXMLStreamReader(StaxUtils.java:1681)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition(WSDLManagerImpl.java:208)
… 8 more
解决方法:如下包必加
cxf-2.7.7.jar
neethi-3.0.2.jar
stax2-api-3.1.1.jar
woodstox-core-asl-4.2.0.jar
wsdl4j-1.6.3.jar
xmlschema-core-2.0.3.jar

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值