[英]Dynamic client using JaxWsDynamicClientFactory (Apache CXF)
I want to make a dynamic client to invoke the web service that I created. 我想创建一个动态客户端来调用我创建的Web服务。 I tried using JaxWsDynamicClientFactory
as mentioned in its official site but I am not getting any ouput. 我尝试使用JaxWsDynamicClientFactory
,如其官方站点中所述,但没有得到任何输出。 Instead, I am getting NullPointerException
. 相反,我得到了NullPointerException
。
JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance();
Client c = dcf.createClient("http://localhost:8080/service/SearchingSEI?wsdl");
The second line is throwing the exception. 第二行抛出异常。
Stack trace: 堆栈跟踪:
Exception in thread "main" 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:599)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:367)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:235)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:228)
at org.apache.cxf.endpoint.dynamic.DynamicClientFactory.createClient(DynamicClientFactory.java:183)
at com.client.dynamic.DynamicClientFactory.main(DynamicClientFactory.java:24)
I have no idea what the problem is. 我不知道是什么问题。 Any suggestions would be a great help. 任何建议都会有很大的帮助。 Thanks. 谢谢。
You need to run the code using a JDK, not a JRE. 您需要使用JDK而不是JRE运行代码。 The NPE is happening in the following bit of CXF's Compiler
class NPE在CXF的Compiler
类的以下位发生
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
compiler
is null if you run in a JRE. 如果您在JRE中运行,则compiler
为null。
That is because of CXF using JRE7 instead of JDK7. 这是因为CXF使用JRE7而不是JDK7。 When you install JDK in windows, by default JRE also installed and all preferences are pointed to JRE. 在Windows中安装JDK时,默认情况下也会安装JRE,并且所有首选项都指向JRE。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.