I have an object which implements Serializable, and have the
serialVersionUID
generated by serialver. When I have it, I put it in a SealedObject to
encrypt
it, and write it to a file.
The problem, as long as I do not recompile my Serializable class, I can
open my file, deserialize and decrypt and get back my object.
If I recompile my Serializable class (without changing the file, just
recompile), I can't get my object back anymore. Exception message
is shown below.
The issue is, there does not seem to have problems on only my Debian
Linux 2.4.22 machine. There does not seem to be any problem on Windows
machines (XP and W2K).
My settings are:
OS: Debian Linux 2.4.22
JDK: 1.4.2 (Sun)
Here's the exception:
java.io.InvalidClassException: IDPasswordSafe$Record; local class
incompatible: stream classdesc serialVersionUID = 4468959199448246293,
local class serialVersionUID = -8112619876065131920
at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:463)
at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1521)
at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1435)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1626)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.util.HashMap.readObject(HashMap.java:1006)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1769)
at
java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at javax.crypto.SealedObject.getObject(DashoA6275)
at
com.idsignet.security.password.IDPasswordManager.<init>(IDPasswordManager.java:105)
at
com.idsignet.security.password.IDPasswordManager.getInstance(IDPasswordManager.java:197)
at com.idsignet.desktop.login.Login.doLogin(Login.java:118)
at com.idsignet.desktop.login.Login.run(Login.java:162)
at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:257)
at
org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:104)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.core.launcher.Main.basicRun(Main.java:279)
at org.eclipse.core.launcher.Main.run(Main.java:742)
at org.eclipse.core.launcher.Main.main(Main.java:581)
Thanks for any help
Lothar Kimmeringer - 12 May 2004 23:25 GMT
> If I recompile my Serializable class (without changing the file, just
> recompile), I can't get my object back anymore. Exception message
[quoted text clipped - 12 lines]
> incompatible: stream classdesc serialVersionUID = 4468959199448246293,
> local class serialVersionUID = -8112619876065131920
Set the serialVersionUID directly in the class, that should
fix the problem.
Regards, Lothar

Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!
scorpion - 13 May 2004 00:45 GMT
> Set the serialVersionUID directly in the class, that should
> fix the problem.
That's what I'm talking about in the line of my post. It's
already set. And it's working just fine one Windows, but
everytime I recompile the class on Linux, it can't deserialize
anymore.
Lothar Kimmeringer - 13 May 2004 07:17 GMT
>> Set the serialVersionUID directly in the class, that should
>> fix the problem.
[quoted text clipped - 3 lines]
> everytime I recompile the class on Linux, it can't deserialize
> anymore.
Sorry, was a little bit late when I responded. A snippet of the
code doing the serialization and deserialization might help.
I learned that you really have to watch out that there is no
String-conversion being involved (that might happen when using
an InputReader).
Regards, Lothar

Signature
Lothar Kimmeringer E-Mail: spamfang@kimmeringer.de
PGP-encrypted mails preferred (Key-ID: 0x8BC3CD81)
Always remember: The answer is forty-two, there can only be wrong
questions!