Skip to main content

null pointer with wsgen and JSONObject

2 replies [Last post]
jetaber
Offline
Joined: 2007-09-21
Points: 0

Very new to JAX-WS and I am following the example on http://java.sun.com/developer/technicalArticles/J2SE/jax_ws_2/. I am using jdk 1.6.013. I would like to return a JSON object via a web service call.

This is the code snippet:

import javax.jws.WebService;
import javax.xml.ws.BindingType;

import org.json.simple.JSONObject;
import org.jvnet.jax_ws_commons.json.JSONBindingID;

@WebService
@BindingType (JSONBindingID.JSON_BINDING)

public class CircleFunctions {

public JSONObject getJsonObject() {
JSONObject foo = new JSONObject();
foo.put("foo", "Bar");
return foo;
}

When I run wsgen against the project I get the following error:

"C:\Program Files\Java\jdk1.6.0_13\bin"\wsgen.exe -cp ".."\classes;".."\ws\jaxws -d ".."\classes ws.CircleFunctions

Problem encountered during annotation processing;
see stacktrace below for more information.
java.lang.NullPointerException
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.isSubtype(WebServiceAP.java:345)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.isRemote(WebServiceAP.java:340)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalType(WebServiceVisitor.java:750)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalMethod(WebServiceVisitor.java:601)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.methodsAreLegal(WebServiceVisitor.java:573)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.isLegalImplementation(WebServiceVisitor.java:491)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.shouldProcessWebService(WebServiceVisitor.java:306)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceVisitor.visitClassDeclaration(WebServiceVisitor.java:109)
at com.sun.tools.apt.mirror.declaration.ClassDeclarationImpl.accept(ClassDeclarationImpl.java:95)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.buildModel(WebServiceAP.java:311)
at com.sun.tools.internal.ws.processor.modeler.annotation.WebServiceAP.process(WebServiceAP.java:252)
at com.sun.mirror.apt.AnnotationProcessors$CompositeAnnotationProcessor.process(AnnotationProcessors.java:60)
at com.sun.tools.apt.comp.Apt.main(Apt.java:454)
at com.sun.tools.apt.main.JavaCompiler.compile(JavaCompiler.java:258)
at com.sun.tools.apt.main.Main.compile(Main.java:1102)
at com.sun.tools.apt.main.Main.compile(Main.java:964)
at com.sun.tools.apt.Main.processing(Main.java:95)
at com.sun.tools.apt.Main.process(Main.java:85)
at com.sun.tools.apt.Main.process(Main.java:67)
at com.sun.tools.internal.ws.wscompile.WsgenTool.buildModel(WsgenTool.java:197)
at com.sun.tools.internal.ws.wscompile.WsgenTool.run(WsgenTool.java:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at com.sun.tools.internal.ws.Invoker.invoke(Invoker.java:100)
at com.sun.tools.internal.ws.WsGen.main(WsGen.java:38)
error: compilation failed, errors should have been reported

I am missing something, but I have no idea what it is. Any help is greatly appreciated.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
jetaber
Offline
Joined: 2007-09-21
Points: 0

now at run-time i get an error:

Exception in thread "main" javax.xml.ws.WebServiceException: Wrong binding ID: https://jax-ws-commons.dev.java.net/json/
at com.sun.xml.internal.ws.api.BindingID.parse(BindingID.java:263)
at com.sun.xml.internal.ws.api.BindingID.parse(BindingID.java:314)
at com.sun.xml.internal.ws.spi.ProviderImpl.createAndPublishEndpoint(ProviderImpl.java:99)
at javax.xml.ws.Endpoint.publish(Endpoint.java:170)
at ws.WSDriver.main(WSDriver.java:60)

jetaber
Offline
Joined: 2007-09-21
Points: 0

Found the answer, have to have the json-simple jar in the class path of the wsgen call.