• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

the XMLEncoder (java.beans)

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>

No others properties!
What I do wrong.
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you would post your Java class for us to see as well.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and here comes the class :

..................




Edit Comment: Added [ code ] [ / code ] tags.
[ November 04, 2004: Message edited by: Madhav Lakkapragada ]
 
Axel Janssen
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic