Win a copy of Microservices Testing (Live Project) this week in the Spring forum!
  • 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:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

Trying to use XMLEncoder

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Greetings, previous post on same issue was probably to confusing, so I have simplified the code; Sorry if my example is long.









Why do I get this error on the XML version?

java.lang.InstantiationException: Dog
Continuing ...
java.lang.Exception: XMLEncoder: discarding statement XMLEncoder.writeObject(Dog);
Continuing ...
My Dog's name is Tank
Tank has 4 number of legs.
Persisting nativeTank
Persisted nativeTank
Persisting xmlTank
Persisted xmlTank
 
Marshal
Posts: 27284
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I read the documentation for XMLEncoder, it's supposed to be used for serializing JavaBeans. At least, that's what it says. Now, what's a JavaBean? Here's the link to what Wikipedia says it is: http://en.wikipedia.org/wiki/JavaBean.

Now, read what it says a JavaBean class must have. Does your Dog class have all of those features?
 
Kurt Harless
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I figured it out... from this link webpage

I needed a no-arg constructor to satisfy the bean methodology of the factory creating the xml.

Yea....
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic