Trouble with InvalidClassException when running application in Eclipse.

A

aaronfude

Hi,

My actuall situation is to convoluted to describe fully, but basically
my servlet serializes and my application, which I run out of Eclipse,
deserializes and I get

mypackage.MyClass$1; local class incompatible: stream classdesc
serialVersionUID = -6759369633728135399, local class serialVersionUID
= 8248309381925280497

This does not happen when I compile and run the classes outside of
Eclipse.

Any ideas on how fix this?
 
M

Manish Pandit

Hi,

My actuall situation is to convoluted to describe fully, but basically
my servlet serializes and my application, which I run out of Eclipse,
deserializes and I get

mypackage.MyClass$1; local class incompatible: stream classdesc
serialVersionUID = -6759369633728135399, local class serialVersionUID
= 8248309381925280497

This does not happen when I compile and run the classes outside of
Eclipse.

Any ideas on how fix this?

You can override the serialVersionUID in your data object that you're
serializing.

Something like :

private static final long serialVersionUID = 1L;

However, you will have to change this ID or figure out compatiblity
(via externalization instead of serialization?) whenever you add/
remove state variables.

Personally, I prefer externalization over serialization due to that
fact that I have larger control (write to XML/CSV/compress/encrypt..)
and I can handle versions of data objects in a clear fashion.

-cheers,
Manish
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top