0

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 = new 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?

Drew Sears
  • 12,732
  • 1
  • 30
  • 40
Venatu
  • 1,206
  • 1
  • 13
  • 24

2 Answers2

3

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.

Dave W. Smith
  • 23,168
  • 4
  • 38
  • 43
  • That solved it. Organize import had chosen that package, rather than the com.google.gdata.data. DateTime option. I shouldn't just press finish! Worked ok as raw data into the datastore though weirdly. Thanks – Venatu Sep 28 '11 at 22:34
2

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.

Community
  • 1
  • 1
Guido
  • 44,623
  • 26
  • 117
  • 170
  • I was unaware of the performance issue, and now Im going to look into swapping over. Thank you very the warning – Venatu Sep 28 '11 at 22:35