This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Only new Instance of object is serializable?

 
Ben Flowers
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Basicaly im trying to save my object to file, but im getting a NotSerializableException
However if i create a new object then it works fine.


the above code fails on the second line but the first runs?
Does anyone knwo why this is happening or how i can fix this?
Thanks,
Ben
 
Rob Spoor
Sheriff
Pie
Posts: 20669
65
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your old object probably has a field that is not serializable. When an object is serialized, all of its non-transient fields are also serialized, and therefore these must be serializable as well.
 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you look at the error message more carefully, you will notice that it mentions the name of the class which was not serializable.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic