For XML, the enhanced mode without default constructor is supported for some JVMs only.
if ( canUseSun14ReflectionProvider() ) { String cls = "com.thoughtworks.xstream.converters.reflection.Sun14ReflectionProvider"; reflectionProvider = (ReflectionProvider) loadClass(cls).newInstance(); } else { reflectionProvider = new PureJavaReflectionProvider(); } The list of supported JVMs contains Sun, IBM etc., but not Oracle. You wrote you use Oracle JVM 1.7. Xstream believes it is not supported and just uses the pure mode, not the enhanced mode. A workaround: System.setProperty("java.vm.vendor", "Sun"); A better solution: Use a newer version of Xstream, where it is already fixed, like 1.4.1 or newer. Xybek wrote: > > Hello, > > I'm getting this error when trying to "deserialize": > > Cannot construct MyClass as it does not have a no-args constructor. > > Looking at the docs, it means that Xtream 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? > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > > > -- View this message in context: http://old.nabble.com/XStream-no-in-enhanced-mode--tp35247159p35385084.html Sent from the xstream - user mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email