cxf调用webservice时报错汇总

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

还可能是
cxf调用webservice时报错汇总

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