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
0
votes
1 answer

Programmatically Adding SerialVersion Ids for Java files

We have hundreds of java Entities which are reverse engineered through Hibernate tools. The Entity classes seem to implement java.io.Serializable interface, but doesn't have serialVersionUID. We are tasked with adding serialVersionUID to these…
Vinoth Kumar C M
  • 10,378
  • 28
  • 89
  • 130
0
votes
1 answer

What content does getSerialVersionUID use to determine the UID?

So, I have a large project that serializes many things when saving a configuration, and had to do a re-design of a large section of it. Since I had already defined the serialVersionUID field for a lot of classes, I wanted to know which files I…
Aaron Marcus
  • 153
  • 2
  • 13
0
votes
2 answers

Java: serialize / deserialize failed because of `ClassNotFoundException`

I have a Pilot class, and an instance of that class: bobThePilot. I serialize bobThePilot to a String and copy that to my my hard disk. Then I create a new project and recreate the Pilot class (exactly identical as before).... And then I create…
smftr
  • 923
  • 3
  • 17
  • 31
0
votes
2 answers

serialVersionUID Exception

I'm currently writing a project where I have a serializable class ClientRepository. The class don't specifies any serialVersionUID. When I try to run my program, I got following Exception: Exception in thread "main" java.io.InvalidClassException:…
VincentDS
  • 310
  • 2
  • 8
0
votes
2 answers

Uniqueness of serial version id in POJO Class

One more silly question. But wanted to ask because its spinning my head from last 1 hour. We all know serialVersionUID is unique. What is the level of uniqueness? Should it be unique in the project or workspace or server? Will it cause…
Mithun Khatri
  • 636
  • 3
  • 9
  • 22
0
votes
1 answer

JSP useBean - Property not found on type mybeans.FrageAntwortListeBean

I'm struggeling on this and I can't figure out why this error occurs. I have a bean: package mybeans; import java.io.Serializable; public class FrageAntwortListeBean implements Serializable { private static final long serialVersionUID = 1L; …
creativeby
  • 859
  • 6
  • 10
0
votes
3 answers

why user defined serialVersionUID is not used while desialization?

public class Employee2 implements java.io.Serializable { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } i first serialized the Employee2 object.Then added…
M Sach
  • 33,416
  • 76
  • 221
  • 314
0
votes
2 answers

The program is not executed - compilation warnings

I am a new java programmer. I am trying to execute this program in eclipse but the error is The serializable class LoveJava does not declare a static final serialVersionUID field of type long. private static final long serialVersionUID = 1L;…
0
votes
5 answers

Why do I need a brace after my serialVersionUID?

I had a syntax error one the line with the serialVersionUID. to fix this error i had to place a bracket at the end of that line and close it at the end of my code... my question is Why? There was no need for this in the file that contains the…
Sage1216
  • 83
  • 1
  • 2
  • 7
0
votes
2 answers

Java error declaring serialVersionUID inside JPanel

I'm getting this error that's really frustrating me from this bit of script... JPanel menu = new JPanel() { private static final long serialVersionUID = 1L; JTextArea output = new JTextArea(5, 30) { /** …
tincopper2
  • 79
  • 10
0
votes
1 answer

Java: Why does my object instance have two serialVersionUIDs?

I am working with Glassfish 3.1.2.2, eclipse-link as JPA provider and Java JDK-6u31. My application is 3-tiered with a stand-alone Swing client running on its own JVM on the client machines. Communication with EJBs by JNDI lookups and @Remote…
salocinx
  • 3,715
  • 8
  • 61
  • 110
-1
votes
1 answer

private static final long serialVersionUID = 1L;

What is private static final long serialVersionUID = 1L in the below code? public class Authenticator extends HttpServlet { private static final long serialVersionUID = 1L; protected void doPost(HttpServletRequest request,…
-1
votes
1 answer

Serialization incompatibility between class generated by ajc and javac

Recently I found out that some classes compiled by Java (Java 8) and by ajc (v.1.9.2) are not serialization-compatible. By serialization-compatibility I mean that calculated default serialVersionUID are not same. Example: public class Markup…
turbanoff
  • 2,439
  • 6
  • 42
  • 99
-1
votes
2 answers

Applet (does not declare a static final serialVersionUID field of type long)

I just began learning Java programming. I made this one program given in the first chapter on Applets (The applet class) and it gave me this error. I tried to find a solution but couldn't. According to the book this program should display a window…
Ghanendra
  • 363
  • 6
  • 15
-3
votes
3 answers

Im getting an error in my class in Eclipse

import acm.graphics.*; import acm.program.*; import java.awt.*; public class MyRobot extends GraphicsProgram { } } That is the code I wrote and whenever I put extends GraphicsProgram or ConsoleProgram, it tells me The…
1 2 3
8
9