• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

the XMLEncoder (java.beans)

 
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and here comes the class :

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




Edit Comment: Added [ code ] [ / code ] tags.
[ November 04, 2004: Message edited by: Madhav Lakkapragada ]
 
Ranch Hand
Posts: 2166
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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>
 
reply
    Bookmark Topic Watch Topic
  • New Topic