Questions tagged [serialversionuid]

`serialVersionUID` is an optional attribute of Java classes to indicate the standard serialization/deserialization format version. Used to detect if a serialized object is incompatible with the deserialization process/class.

Documented in java.io.Serializable:

The serialization runtime associates with each serializable class a version number, called a serialVersionUID, which is used during deserialization to verify that the sender and receiver of a serialized object have loaded classes for that object that are compatible with respect to serialization. If the receiver has loaded a class for the object that has a different serialVersionUID than that of the corresponding sender's class, then deserialization will result in an InvalidClassException. A serializable class can declare its own serialVersionUID explicitly by declaring a field named "serialVersionUID" that must be static, final, and of type long:

ANY-ACCESS-MODIFIER static final long serialVersionUID = 42L;
122 questions
1
vote
0 answers

Serialization using serialVersionUid

As of now I am clear with the concept of serialization as well as the use of serialVersionUid. I have a doubt and would appreciate you all in helping me understand this scenario. Tried a lots but not getting appropriate help from Google. 1)Sender…
log N
  • 925
  • 9
  • 33
1
vote
1 answer

Failed to connect to spark master:InvalidClassException: org.apache.spark.rpc.RpcEndpointRef; local class incompatible

I Installed Spark on Linux machine. the version is spark-1.6.2-bin-hadoop2.6.tgz. and then I start the Spark using ./sbin/start-all.sh I trid to run the examples JavaWordCount.java in Eclipse. but always failed. someone can helps me? the version of…
michelle
  • 165
  • 2
  • 3
  • 13
1
vote
2 answers

Why serialVersionUID in java must be static, final, and of type long?

Why serialVersionUID must be declared as static, final and of type long variable? Does this serialVersionUID be unique? What happens when two or more classes contains the same serialVersionUID? How will this versionUID be useful in this case to…
user1391703
1
vote
1 answer

Serial version id mismatch issue between server and client class

I am facing issues with serial version id mismatch. My server is having code with serialVersionID=20150301L; and myt client code is having diffrent so changed it manually but still facing the same issues. Error: java.rmi.UnmarshalException: error…
1
vote
0 answers

Array classes cannot declare an explicit serialVersionUID

Declaring an explicit serialVersionUID is mostly recommended for serialization but not for array classes as per the last line of javadoc for serialization Array classes cannot declare an explicit serialVersionUID, so they always have the default…
SacJn
  • 777
  • 1
  • 6
  • 16
1
vote
1 answer

Compatible changes and serialversionUID

I need an advice about compatible changes and serialVersionUID (http://docs.oracle.com/javase/6/docs/platform/serialization/spec/version.html#6678). I work on a system with a 'client' project which communicates with 'server' project using RPC…
Uros
  • 38
  • 4
1
vote
1 answer

java.io.InvalidClassException: serialization from string to object fail java

I have an Object called Doodle, I serialize it into a String and it's ok. The problem arrises when I try to deserialize the object, the error is this: java.io.InvalidClassException: java.util.ArrayList; local class incompatible: stream classdesc…
user3457185
  • 175
  • 1
  • 1
  • 7
1
vote
1 answer

Reflection a list of object which is serializable

I have asked a question in : reflect a list object I actually got my answer just want to understand why when do this I will hits illegalArgumentException : Can not set static final ArrayList SerialVersionUID to java.lang.long. But when I do one…
user236501
  • 8,538
  • 24
  • 85
  • 119
1
vote
3 answers

Spring Batch 2.2.3 exception - Shouldn't be illegal to access field 'serialVersionUID'

I have a Spring Batch job that started throwing this odd exception. I wish I had more information than this stack trace, and I might, but I just don't know what to provide. Searching around I've only found one other person with this particular…
wsams
  • 2,499
  • 7
  • 40
  • 51
1
vote
6 answers

Find which class in which jar has a given serialVersionUID

When I get a java.io.InvalidClassException, it gives me the serialVersionUID that it wants, and the serialVersionUID that it got. Is there an easy way to tell which of my dozens of jars using the wrong serialVersionUID? Update: I should mention…
Paul Tomblin
  • 179,021
  • 58
  • 319
  • 408
1
vote
0 answers

serializable or serial version in java stream

Why am i getting this error? Though i have set the serial version but i am not able to do my job .Actually i am trying to read from objectoutputstream . I need data of imageicon from the object outputstream and i am getting error at that line.what…
Developer
  • 385
  • 1
  • 3
  • 18
0
votes
2 answers

Why doesn't the Hibernate generate a DDL with column for serialVersionUID?

I get this DDL (postgres target) when I add the goal hbm2ddl using the Maven plugin hibernate3-maven-plugin: create table listing ( id varchar(36) not null, hash_code int4 not null, version int4, name varchar(100), primary key…
Dennis
  • 747
  • 7
  • 15
0
votes
1 answer

Java deserialization and InvalidClassException

This is hard to describe, so I hope I make this clear. We compile a large application containing many EJB's and Java Swing client code into a typical class file hierarchy. We then build a .EAR containing all compiled classes and deploy the .EAR to…
J Slick
  • 929
  • 11
  • 17
0
votes
0 answers

Eclipse stops generating new serialVersionUID numbers after introducing either inheritance or generics to the class. Is there a fix?

I have a custom exception class that extends a parent exception class. I also use generics in my constructor, but not on my exceptions, because exceptions cannot be generic. Ever since I did the inheritance/generics part, I have tried to generate…
0
votes
0 answers

Sonarlint recommends to remove serialVersionUID in exception classes

I have a class MyGenericException that extends Exception: public class MyGenericException extends Exception { private static final long serialVersionUID = 7332351790980555724L; private final String code; public…
harry-potter
  • 1,981
  • 5
  • 29
  • 55
1 2 3
8 9