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/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值