0
I’m trying to create a WebService
return to me one or more data from the database, using as return JSON
.
@Path("teste")
@Produces(MediaType.APPLICATION_JSON)
public JSONObject teste() {
JSONObject obj = new JSONObject();
obj.put("teste", "teste 1");
obj.put("teste2", "teste 2");
return obj;
}
But when running through the URL, the following error occurs (I only took the first few lines):
GRAVE: Servlet.service() for servlet [Jersey REST Service] in context with path [/TrabalhoWeb1] threw exception [org.glassfish.jersey.server.ContainerException: java.lang.NoClassDefFoundError: org/apache/commons/lang/exception/NestableRuntimeException] with root cause java.lang.ClassNotFoundException: org.apache.commons.lang.exception.NestableRuntimeException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1291) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1119) at java.lang.ClassLoader.defineClass1(Native Method)
And when I do debug, the error occurs when it will instantiate the object JSONObject
.
I have no idea what to do.
Ta remembering to import the class from the json object ?
– Luís Felipe Dal Molin
@Felipedm Yes, The problem was with the library itself Json_lib, switched to the Gson google.
– Reinaldet