Reputation: 1562
I want to make a dynamic client to invoke the web service that I created. I tried using JaxWsDynamicClientFactory
as mentioned in its official site but I am not getting any ouput. Instead, I am getting 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.
Upvotes: 2
Views: 5255
Reputation: 31
That is because of CXF using JRE7 instead of JDK7. When you install JDK in windows, by default JRE also installed and all preferences are pointed to JRE.
Upvotes: 1
Reputation: 32407
You need to run the code using a JDK, not a JRE. The NPE is happening in the following bit of CXF's Compiler
class
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null);
compiler
is null if you run in a JRE.
Upvotes: 3