Gson on Appengine
I am trying to use Gson to parse a class for storing as a blob on Google Appengine. I have added the file gson-1.7.1.jar to my build path and the web-inf/lib folder. My app compiles fine, but when attempting to run, the program fails with an error on Gson g = n开发者_如何学编程ew Gson();
The error message is:
java.lang.NoClassDefFoundError: Lcom/google/appengine/repackaged/org/joda/time/DateTime;
Has anyone found the same issue, or managed to get it to work? Any alternative JSON parsers that are known to work with appengine?
GSon itself has no dependency on joda. Are you importing from repackaged
? That's not supported.
I'm using GSon 1.7.1 with SDK 1.5.4, and it works fine, but I don't have DateTimes represented in JSON.
It seems to be a known issue: http://code.google.com/p/googleappengine/issues/detail?id=2388 Try to include Joda Time library under WEB-INF/lib but I don't think that solves your problem.
I found Jackson better than Gson (performance, project activity, better docs, ...). Take a look at this related question that compares Jackson vs Gson.
精彩评论