NoClassDefFoundError: in Google App Engine app while creating Gson instance

Is there something tricky about using Gson in Google App Engine App? I placed gson jar in war/lib and included it in the build path. I'm using Eclipse.

Code compiles however app keeps failing at line:

Gson gson = new Gson(); 

with:

java.lang.NoClassDefFoundError: com/google/gson/Gson

Answers


A NoClassDefFoundError specifies that you have a particular class available at compile time but missing or not initialized during runtime. In your case com/google/gson/Gson class is found at compile time as gson jar is in your lib. But during runtime it is either not present or not initialized. Check for a conflict of gson jar or if there is an ExceptionInInitializerError in the stacktrace. You may further understand it here - Debugging a NoClassDefFoundError


I know GAE by name only, but I have that kind of error in Eclipse when I have a dynamic web project and I forget to deploy libs I used to build.

So, maybe you can solve by going into Deployment Assembly section of your project and add libs that you have in your build path.


The problem was that I placed library under war/libs and not under war/WEB-INF/lib


Need Your Help

How to optimize graph traversals in ArangoDB?

graph-databases arangodb aql

I primarily intended to ask this question : "Is ArangoDB a true graph database ?"

Issue with char[] in VS2008 - why does strcat append to the end of an empty array?

c++ arrays char

I am passing an empty char array that I need to recursively fill using strcat(). However, in the VS debugger, the array is not empty, it's full of some weird junk characters that I don't recognise.