1

I have a serializable java class and when I add either of the following methods. I get this error

" local class incompatible: stream classdec serialversionUID= ...., local class serialversionUID=..."

added methods:

public HashMap<Long, BookIndex> getBookIndexMap() {
    return bookIndexMap;
}

public String getDataFileName() {
    return dataFileName;
}

what is causing this and how can I correct it?

trs
  • 2,454
  • 13
  • 42
  • 61

3 Answers3

-1

I solved it by doing the following:

Working in Eclipse Neon.

On Tomcat Server

  • Clean Tomcat Work Directory...
  • Clean... (to do something, just in case)

then

Project

  • 'Clean...' select your project and click 'Ok'
Paul Roub
  • 36,322
  • 27
  • 84
  • 93
  • That wouldn't take care of existing serializations, such as to files or databases. This is not the correct solution. – user207421 Aug 16 '23 at 23:56
-1

This article may be helpful, by changing the class's method signatures, previous serialized forms are incompatible unless the classes have the same serialVersionUID.

Henry Ecker
  • 34,399
  • 18
  • 41
  • 57
j128
  • 58
  • 1
  • 6
  • The Object Serialization Specification would be a lot more helpful, as it is a normative specification, not just some arbitrary third-party Internet junk. – user207421 Aug 16 '23 at 23:55
-1

Even Though the serialVersionUID is same, some changes are incompatible to sync with the previous serialized form.

link is here

Community
  • 1
  • 1
Rajkumar Palani
  • 2,211
  • 2
  • 19
  • 25