This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I try to serilaize an Object with the XMLEncoder but all that I got is an Exception because I don't have a default constuctor :java.lang.InstantiationException and if I create one I get : <?xml version="1.0" encoding="UTF-8"?> <java version="1.4.2_05" class="java.beans.XMLDecoder"> <object class="MyClass"/> </java>
Though I don't know no much about XMLEncoder, I got the impression that you need a constructor without any parameters. As we all know Java creates automatically default constructor, if there is no constructor in class. But your class has:
there is no without-parameters constructor.
Often things that work with introspection impose the restriction that the class has a constructor without parameters.
So you might put in a
and set property name other way.
Axel [ November 04, 2004: Message edited by: Axel Janssen ]
I tried with an default constructor but then my xml file was : <?xml version="1.0" encoding="UTF-8"?> <java version="1.4.2_05" class="java.beans.XMLDecoder"> <object class="com.oce.prismapro.xpdc.util.presistentcomposite.Node"/> </java>