1

I'm getting this error when trying to "deserialize" an object:

Cannot construct MyClass as it does not have a no-args constructor.

Looking at the docs, it means that XStream is not running in enhanced mode?

However, in the same JVM and using the same class the Google Gson library can serialize and deserialize objects without problem:

MyClass c;
c = (MyClass) new Gson().fromJson(json, MyClass.class);

So why XStream can't do to XML what Gson can do for JSON? Is this easy to patch in the XStream code or is this a limitation that is not easy to get around with?

I need to be able to serialize / deserialize Objects even those that have no-args constructor using this XStream library.

1 Answers1

0

XStream requires that your class have a constructor with no args.

Those constructors don't have to be public, but they need to exist.

pablosaraiva
  • 2,343
  • 1
  • 27
  • 38
  • Yah I know, however I want my library to be able to handle classes with no no-args, however it seems that the Security manager in the GAE SDK won't allow such (where Google Gson is allowed, where other don't have such privilege) –  Apr 05 '13 at 03:21