Caused by: java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC

Caused by: java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC

缺少com/sun/tools/internal/xjc/api/XJC

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

蕃薯耀 2016年2月29日 14:41:19 星期一

http://fanshuyao.iteye.com/

 

 

Exception in thread "main" java.lang.IllegalStateException: Unable to create schema compiler
	at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:663)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createSchemaCompiler(DynamicClientFactory.java:422)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:306)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:240)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:233)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:188)
	at com.lqy.spring.cxf_client.Main.main(Main.java:12)
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:648)
	at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompilerWithDefaultAllocator(JAXBUtils.java:655)
	... 6 more
Caused by: java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC
	at java.lang.Class.forName0(Native Method)
	at java.lang.Class.forName(Unknown Source)
	at org.apache.cxf.common.jaxb.JAXBUtils.createSchemaCompiler(JAXBUtils.java:641)
	... 7 more

 

一、问题描述:

在CXF调用接口的代码时,跳出这样的错误:

Caused by: java.lang.ClassNotFoundException: com/sun/tools/internal/xjc/api/XJC

 

JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
        org.apache.cxf.endpoint.Client client = dcf.createClient("http://localhost:8080/cxf/ws/getUserName?wsdl");
        //sayHello 为接口中定义的方法名称   张三为传递的参数   返回一个Object数组
        //Object[] objects=client.invoke("getUserName", new Object[]{}); 
        Object[] objects=client.invoke("getUserNameByString", "张三"); 
        //输出调用结果
        System.out.println(objects[0].toString()); 

 

二、解决

但网上都说在jaxb-xjc这个Jar包里,其实是不对的,因为引用的是Jdk lib下的tools.jar

D:\Java\jdk1.6.0_45\lib\tools.jar,缺少的是这个包,把这个包引用就正常了。

 

 三、注意

加了tools.jar,再添加jaxb-xjc也会报错,所以不要再添加jaxb-xjc.jar

<dependency>

<groupId>com.sun.xml.bind</groupId>

<artifactId>jaxb-xjc</artifactId>

<version>2.2.11</version>

</dependency>

 

Exception in thread "main" java.lang.IllegalStateException: Unable to write generated Java files for schemas: null
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:354)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:240)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:233)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:188)
	at com.lqy.spring.cxf_client.Main.main(Main.java:12)
Caused by: java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy27.build(Unknown Source)
	at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:352)
	... 4 more
Caused by: java.lang.NoSuchMethodException: com.sun.codemodel.internal.JCodeModel.build(java.lang.Object)
	at java.lang.Class.getMethod(Unknown Source)
	at org.apache.cxf.common.util.ReflectionInvokationHandler.invoke(ReflectionInvokationHandler.java:85)
	... 6 more

 

 

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

蕃薯耀 2016年2月29日 14:41:19 星期一

http://fanshuyao.iteye.com/

你可能感兴趣的:(蕃薯耀,蕃薯)