This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Java in General and the fly likes InvalidClassException: Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "InvalidClassException: " Watch "InvalidClassException: " New topic
Author

InvalidClassException:

Hemant Khurana
Greenhorn

Joined: Jan 11, 2007
Posts: 27
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

Joined: Oct 13, 2005
Posts: 32674
    
    4
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

Joined: May 14, 2007
Posts: 107
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: InvalidClassException:
 
Similar Threads
How to run jar file in jsp?
java.rmi.ServerException etc
"Could not find stored procedure" Error
In Access,Oracle8i PE ResultSet is not scrolling
java.io.IOException: There is not enough space on the disk JNLP