This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

re. serialVersionUID

 
Bob Chandler
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Due to the fact that I was unable to continue with my last topic, I have to begin a new one:
Here is the story so far...
Bob Chandler
ranch hand
Member # 64584
posted May 05, 2004 08:01 AM
--------------------------------------------------------------------------------
Hey there Java peeps,
having problems with some code I'm working on... hope you can help.
I have a class that implements Serializable and, therefore has serialVersionUID number when I run serialVer tool. I'm clear about this part.
However, when I run the part of my code which is retrieving a record from the database, I sometimes get an error that reads:
an Exception occurred: Cabin; local class incompatible: stream classdesc serialVersionUID = 3448415719576074304, local class serialVersionUID = -1390977758539970494
If I have created the record in the current session, it runs ok....
Any suggestions?
Bob

--------------------------------------------------------------------------------
Posts: 31 | Registered: Jan 2004 | IP: Logged

Jeanne Boyarsky
bartender
Member # 50496
posted May 05, 2004 06:07 PM
--------------------------------------------------------------------------------
Bob,
Well it's saying that you changed the serialver id. When this id changes, you are stating that the object should not be read in.
Did you change the id on purpose? Are old objects in the database from a previous deployment with a different id?

--------------------------------------------------------------------------------
Posts: 916 | Registered: May 2003 | IP: Logged


ok, Jeanne, I have not changed or even referred directly to the serialver id in my code.
What's this about previous deployment?
I have written methods that retrieve, modify and persist records back to the database (db is nothing fancy, just a folder in the same directory as my other code files)
The data is still there ie. it doesn't disappear between sessions and the relevant classes implement serializable.
Maybe there is something I don't yet know about - but I just want to be able to access my stored data...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bob,
If the serialUid is different (which is only possible in different deployments) it signifies that the object being serialized has changed in structure. This would be dangerous to read in, so java throws an exception.
Another problem that can cause similar errors if there is more the one copy of the class around. (even if the two copies are identical) Try checking your classpath/jars to make sure you don't inadvertently have an extra one.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to this thread so I can close the duplicate:
for some reason, this forum will not let me add a reply to a post that I start....pah!!
so once again I hope that Jeanne picks this up...
Jeanne
I read your post with interest and, on closer inspection, I have found that the records causing the exception were created before I made further development of the class structure.
I have removed the offending data, re-populated the db and the problem seems to have been resolved
Thank you so much for your help.
all the best,
Bob
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic