Search code examples
javajsonglassfishejbglassfish-3

Java Glassfish-Server Json NoClassDefFoundError: org/json/JSONObject


I'm using Eclipse Neon 3.6.3 and I have a Java EJB project where I try to use Json-Objects to evaluate the response from a REST-Service. I've imported JSONObject:

import org.json.JSONObject;

And added

json-20160810.jar

to the Build Path. After I deployed it on a Glassfish-Server (3.1.2) I get the following Error:

Caused by: java.lang.NoClassDefFoundError: org/json/JSONObject

Solution

  • You probably can solve the problem by putting the JAR into the folder /glassfish3/glassfish/lib and restarting Glassfish.

    A second solution would be to include the JAR in a WAR or EAR file for deployment. There are plenty of tutorials for that on the net, but I'm not sure what you need exactly for Eclipse.