質問

I am getting an error while executing my Java program. Please help me what to do? Error is like as below :

java.io.InvalidClassException: buddyconnect.UserInfo; 
local class incompatible: stream classdesc serialVersionUID = -411616971160539345, 
local class serialVersionUID = -6346841117345473801
BUILD SUCCESSFUL (total time: 0 seconds)
役に立ちましたか?

解決

This error occurs because you have a class (buddyconnect.UserInfo here) implementing Serializable but forgot to include a serialVersionUID.

If you don't declare and initialize that (private static final long) field in your class, the JRE will generate a new, (nearly) random one each time your program is executed again.

As a result, instances of this class serialized by one execution of your program will not be deserializable by another execution of your program.

Declare one at the top of your class, such as in:

public class UserInfo
{
    private static final long serialVersionUID = 0x1b32faab5902bfa3L;
    // etc

他のヒント

It seems you are trying to de-serialize an incompatible class which was serialized using your older version of class.

The developer of the class might have changed some class semantics and therefore have updated the serialVersionUID as well. So de-serialization process is getting failed.

Probably there is problem with serialization of your class. Your versions are different. Try to clear cache of your project. Use mvn clean or rebuild project. This exception is thrown when you made changes of your class and have new versionID and try to read old version of saved object.

From the limited information it appears that you may be having a problem with the serialization / deserialization of an object made for the UserInfo class in buddyinfo. Do you have the source to look at? Some of these problems come from not creating a serialization ID or not maintaining things so you can handle multiple versions of the object created at different times. You might look at the explanation in another StackOverflow question here

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top