This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes De-serialization Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "De-serialization" Watch "De-serialization" New topic


David Marco
Ranch Hand

Joined: Feb 23, 2009
Posts: 44
I'm unable to understand why this program (coded my own) don't work:

If I change line 38 for this:

Then the program runs succesfylly. I'm going crazy!!

Bob Wheeler
Ranch Hand

Joined: Apr 24, 2009
Posts: 317
You have forgotten the 't' in writeObject:

Change it and it will run smoothly.


JavaEnterpriseEditionFaq - TomcatFaq
Peter Murach

Joined: Feb 08, 2009
Posts: 5
Hi David,

You simply did not correctly implement your customized writeObject() method. If you look closely, you have simply swallowed a letter 't'. VM is using a default method writeObject which does not write your integer value returned by Bulb class method getPower( ). Subsequently, when you try to retrieve the value from a serialized file, readInt( ) method throws IOException.


The important thing is not to stop questioning.

Albert Einstein
David Marco
Ranch Hand

Joined: Feb 23, 2009
Posts: 44
Thanks Bob and Peter, I really misspelled the method name.
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

It just goes to show, that some of the most simple errors can be the most frustrating to troubleshoot and solve. An extra set of eyes is often helpful.

-Cameron McKenzie
I agree. Here's the link:
subject: De-serialization
It's not a secret anymore!