InvalidClassException question

A

Aidan

According to the docs, this is exception is thrown:

"when the Serialization runtime detects one of the following problems
with a Class.

* The serial version of the class does not match that of the class
descriptor read from the stream
* The class contains unknown datatypes
* The class does not have an accessible no-arg constructor "


Can someone explain to me what "The class contains unknown datatypes" means?

I'm getting this exception, and can't figure out why. Both sides (local
and remote) use the same class, in the same jar, and run in the same JVM
(which rules out the 1st reason). The class does have a public no-arg
constructor (which rules out the 3rd reason), and I've tried encoding
the serialVersionUID directly in the class just to make sure.



Aidan
 
D

Derek Chen-Becker

Aidan said:
According to the docs, this is exception is thrown:

"when the Serialization runtime detects one of the following problems
with a Class.

* The serial version of the class does not match that of the class
descriptor read from the stream
* The class contains unknown datatypes
* The class does not have an accessible no-arg constructor "


Can someone explain to me what "The class contains unknown datatypes"
means?

I'm getting this exception, and can't figure out why. Both sides (local
and remote) use the same class, in the same jar, and run in the same JVM
(which rules out the 1st reason). The class does have a public no-arg
constructor (which rules out the 3rd reason), and I've tried encoding
the serialVersionUID directly in the class just to make sure.



Aidan

Problem two means that if any of a classes' members are non-primitive,
non-serializable objects, then you can't serialize an instance of that
class.

Derek
 
A

Aidan

Derek said:
Problem two means that if any of a classes' members are non-primitive,
non-serializable objects, then you can't serialize an instance of that
class.

Derek

Thanks Derek - it actually turned out to be an instance of the 1st
problem, since some code had been changed to serialize object instances
to a file. doh!
 
R

Roedy Green

I'm getting this exception, and can't figure out why. Both sides (local
and remote) use the same class, in the same jar, and run in the same JVM
(which rules out the 1st reason). The class does have a public no-arg
constructor (which rules out the 3rd reason), and I've tried encoding
the serialVersionUID directly in the class just to make sure.

Are you getting the problem on write or read?
 
R

Roedy Green

I'm getting this exception, and can't figure out why. Both sides (local
and remote) use the same class, in the same jar, and run in the same JVM
(which rules out the 1st reason). The class does have a public no-arg
constructor (which rules out the 3rd reason), and I've tried encoding
the serialVersionUID directly in the class just to make sure.

have you freshly written these objects with your latest class
definition? Have you utterly proved to yourself you are using
identical code on both ends? You might write an Integer( version ) at
the head of both streams just to be sure.
 

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,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top