error: null pointer exception in JaxWsDynamicClientFactory

13 篇文章 0 订阅
7 篇文章 0 订阅

http://stackoverflow.com/questions/15564388/dynamic-client-using-jaxwsdynamicclientfactory-apache-cxf


        问题:

JaxWsDynamicClientFactory clientFactory = JaxWsDynamicClientFactory.newInstance(); 
        Client client = clientFactory.createClient("http://172.16.41.6:8085/Logd.asmx?wsdl"); 


原因:

You need to run the code using a JDK, not a JRE. The NPE is happening in the following bit of CXF'sCompiler class

   JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
   StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);

compiler is null if you run in a JRE(java/jre  not java/jdk/jre).

在eclipse中执行代码,默认使用eclipse中指定的jre。若指定的jre不在jdk中,无法找到jdk/bin下的编译器,返回null。CXF'sCompiler中即会出现null pointer exception。



解决:

You need to run the code with a JDK. Bear in mind,some IDEs (eg Eclipse) come with their own compiler and will run in a JRE-only situation.

需要使用JAVA安装目录下面的JDK下面的jre

如果你是eclipse的工程很容易出现不是那个目录。。你可以再windows->preferences->java-Install JRE下面去指定,然后修改工程里的JRE引用到正确的JDK的JRE(右击JRE Library System --> properties --> execution environment下拉表)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值