Steven Roose
Steven Roose

Reputation: 2769

GWT can't find org.json while it's in the build path

I have a strange problem. I get an error from Google Web Toolkit stating the following:

com.google.gwt.user.server.rpc.UnexpectedException: Service method 'public abstract 
com.pluspopularity.model.LinkItem com.pluspopularity.web.client.GreetingService.greetServer(java.lang.String) 
throws java.lang.IllegalArgumentException' threw an unexpected exception: 
java.lang.NoClassDefFoundError: org/json/JSONException

Now, I can find lots of questions about this java.lang.NoClassDefFoundError: org/json/JSONException exception, but they all seem to be fixed by GWT version 2.5 because org.json was since then included in the gwt-dev.jar package.

I have version 2.5 and I can see org.json in my GWT SDK library.

So I have no idea where this error comes from.

Something I noticed: the GWT SDK folder contains a lot of jar files, but only 4 are included when I add it as an SDK in Eclipse: gwt-user.jar, gwt-dev.jar, validation-api-1.0.0.GA-sources.jar and validation-api-1.0.0.GA.jar. In some issues in questions about this error from GWT versions before 2.5 I see mentions of a gwt-servlet-deps.jar file. That file sits inside my GWT SDK folder, but it's not included in the SDK library in Eclipse. I re-installed the GWT SDK via Eclipse but still only those 4 files are included.

Upvotes: 1

Views: 1557

Answers (2)

appbootup
appbootup

Reputation: 9537

org.json.JSONException is present in json-20090211.jar.

enter image description here

Both gwt-user and request-factory-server have dependency on it. In a maven set up it gets copied automatically via request-factory for us since both are in runtime scope.

Upvotes: 0

Thomas Broyer
Thomas Broyer

Reputation: 64541

You get an error at runtime (apparently), on the server-side.

If the Eclipse plugin doesn't do it for you (I have no idea if it's supposed to do it or not), you should go get gwt-servlet-deps.jar (or any JAR that contains org.json) and copy it to your WEB-INF/lib next to gwt-servlet.jar.

Upvotes: 2

Related Questions