• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

InvalidClassException:

 
Hemant Khurana
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am getting a java.io.InvalidClassException: exception at runtime in my application.

The class compiles fine but when i run the application i get this exception.

I have checked the API docs and there are reasons for this to happen

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

I dont understant the first one and the rest 2 dont apply to my case

I am getting a exception when i am changing data types of certain class memeber variables from long to double but then double should not a unknown data type
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you mean you are casting a double or a Double? Read this.

You should have no difficulty casting longs to doubles and vice versa but you ought not to be able to cast Longs and Doubles.

CR
 
Bupjae Lee
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The serial version of the class does not match that of the class descriptor read from the stream

This means that it has same class name between what you do serialize (this means ObjectOutputStream.writeObject()) and what you deserialize (this means ObjectInputStream.readObject()), but it isn't same class.

In java serialize system, every serializable class has its own ID code that called 'serialVersionUID', and it is recommended every serializable class declared that value such as:


If you don't include that, java creates ID according with what methods and fields are declared in that class. So unless you declared ID, that may or may not be changed when you change class.
You can see current ID such as:


serialver utility is in JDK/bin directory.
[ May 15, 2007: Message edited by: Bupjae Lee ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic