java - Why throw CannotResolveClassException on XStream? -
i using follow code:
@xstreamalias("listofmbdo") public class xmllistofmbdo { @xstreamimplicit(itemfieldname = "mbdo") public list<modifybetriebsortdataobject> items = new linkedlist<modifybetriebsortdataobject>(); } public class modifybetriebsortdataobject { @xstreamalias("pk") public integer pk; @xstreamalias("name") public string name; public modifybetriebsortdataobject(final integer pk, final string name) { this.pk = pk; this.name = name; } } public void loadthis() { final string test = "<listofmbdo><mbdo><pk>123456</pk><name>test</name></mbdo></listofmbdo>"; final xstream _xstream = new xstream(new domdriver()); _xstream.processannotations(xmllistofmbdo.class); _xstream.processannotations(modifybetriebsortdataobject.class); final xmllistofmbdo testlist = (xmllistofmbdo) _xstream.fromxml(test); }
the serializationto xml works fine. deserialization throws an
com.thoughtworks.xstream.mapper.cannotresolveclassexception: ....data.xmllistofmbdo : ....data.xmllistofmbdo @ com.thoughtworks.xstream.mapper.defaultmapper.realclass(defaultmapper.java:68) @ com.thoughtworks.xstream.mapper.mapperwrapper.realclass(mapperwrapper.java:38) @ com.thoughtworks.xstream.mapper.dynamicproxymapper.realclass(dynamicproxymapper.java:71) ...
why?
you can try solving deserialization error adding
_xstream.alias("listofmbdo", xmllistofmbdo.class);
Comments
Post a Comment