We do set a serialVersionUID in our classes.  And the problem
happens even when the class is not recompiled.  Just redeployed.
And I think when the serial id doesn't match you get an
InvalidClassException not a ClassCastException.
-----Original Message-----
From: Chris Chen [mailto:ckchris@idream.net]
Sent: Friday, May 31, 2002 12:18 PM
To: jboss-user@lists.sourceforge.net
Subject: Re: [JBoss-user] ClassCastException from serialize, redploy, deserialize

This sounds to me to be more like a Java Class SerializationID issue than JBoss issue. 

Every time you recompile a java class code, the SerializationID is generated.  Supposedly they need to match in order for the Java Runtime to know that they are the same classes.  For instance, what if you changed some code inside the Java class (same name, but added new code)?  When you deserialize, it will cause a ClassCastException as the JDK thinks that the classes are not the same.

What you can technically do is set the SerializationID manually and change it yourself.  It is a public static final long (I think).

However, I may be wrong as it's been a while since I touched object serializations.  I normally use XML in place of serialization for storage these days for comptability reasons.


At 12:06 PM 05/31/2002, you wrote:

I've narrowed down my ClassCastException to
deserializing an Object after redeploying.

I serialize an Object to BLOB in MySQL using
CMP.  Then redeploy and when I deserialize the
object I can't cast the Object to one of it's

Could this be some ClassLoader issue?  The
interface is loaded by a JBoss class loader
and the deserialized object is loaded by
another ClassLoader.

I think I've got a good handle on the problem,
but can't think of a good solution - aside from
not using hot deploy...

Tx for any thoughts!

PGP at ldap://certserver.pgp.com/