String url = "http://localhost:8080/TestSpring/services/HelloWorld?wsdl";
JaxWsDynamicClientFactory factory = JaxWsDynamicClientFactory
.newInstance();
Client client = factory.createClient(url);
Object[] res = client.invoke("sayHi", "李晓辉");
System.out.println(res[0]);

调用的代码就这么简单,但是却始终爆出如下额错误信息:

java.lang.NullPointerException
at org.apache.cxf.common.util.Compiler.useJava6Compiler(Compiler.java:189)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:143)
at org.apache.cxf.common.util.Compiler.compileFiles(Compiler.java:138)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.compileJavaSrc(DynamicClientFactory.java:598)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:367)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:270)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:263)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:198)
at main.java.demo.hw.client.Client.main(Client.java:43)

经过查看Compiler的代码,发现useJava6Compiler方法里面有这么一句“JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();”空指针的异常就是来自这里。产生的原因是没有获得编译环境,也就是JRE设置的问题,需要在eclipse里面把jre设置为jdk下的jre。

友情链接
KaDraw流程图
API参考文档
OK工具箱
云服务器优惠
阿里云优惠券
腾讯云优惠券
华为云优惠券
站点信息
问题反馈
邮箱:[email protected]
QQ群:637538335
关注微信