Bonjour,
J'utilise xstream pour sérialiser et désérialiser mes objetc, cependant j'ai un problème lors de la désérialisation concernant mes objets qui héritent d'une autre classe :
et j'obtiens cette erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9 @XStreamAlias("A") public class TypeA { private String attrA = "testA"; } @XStreamAlias("B") public class TypeB extends TypeA { private String attrB = "testB"; } @XStreamAlias("Ct") public class TypeC extends TypeB { private String attrC = "testC"; }
Merci de votre aide.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 com.thoughtworks.xstream.converters.ConversionException: b : b ---- Debugging information ---- message : b : b cause-exception : com.thoughtworks.xstream.mapper.CannotResolveClassException cause-message : b : b class : com.test.TypeC required-type : com.test.TypeC path : /test/b ------------------------------- at com.thoughtworks.xstream.core.TreeUnmarshaller.convert(TreeUnmarshaller.java:63) at com.thoughtworks.xstream.core.AbstractReferenceUnmarshaller.convert(AbstractReferenceUnmarshaller.java:45) at com.thoughtworks.xstream.core.TreeUnmarshaller.convertAnother(TreeUnmarshaller.java:46) at com.thoughtworks.xstream.core.TreeUnmarshaller.start(TreeUnmarshaller.java:117) at com.thoughtworks.xstream.core.ReferenceByXPathMarshallingStrategy.unmarshal(ReferenceByXPathMarshallingStrategy.java:29) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:832) at com.thoughtworks.xstream.XStream.unmarshal(XStream.java:819) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:767) at com.thoughtworks.xstream.XStream.fromXML(XStream.java:759)...
Partager