Skip to main content
10-Marble
July 5, 2024
Solved

Exception - local class incompatible: stream classdesc serialVersionUID

  • July 5, 2024
  • 2 replies
  • 3231 views
I am using Windchill PDMLink Release 12.0 and Datecode with CPS 12.0.0.1

Getting below error when defining class as serilizable

Suppressing internal message (wt.pom.pomResource/0) wt.pom.PersistenceException: A persistence error occurred. System message follows:
Nested exception is: wt.pom.DatastoreException: A SQL error has occurred. Database system message follows:
Nested exception is: java.io.InvalidClassException: local class incompatible: stream classdesc serialVersionUID = -4417239417148031805, local class serialVersionUID = 1
    Best answer by MP_10433217

    I have received below inputs from PTC to resolve this issue. We should not be modifying serialized class once we assign serialVersionUID

    .

    Root Cause:

    • If we do not define serialVersionUID in Java class, Java will give a default value and every change of the class will have a new value.
    • Then the serialized Java object created with old class will fail to deserialize with new class, because the difference of the serialVersionUID.

     

    The Best Practice as you did:

    • Always define serialVersionUID as 1
    • Never delete any attribute if change the class later, or else the Java object will be failed to deserialize, because the new class has no such attribute.

    2 replies

    avillanueva
    23-Emerald I
    23-Emerald I
    July 9, 2024

    There are a number of articles that have this message in it. Is this a new upgrade or related to some customization?

    https://www.ptc.com/en/support/article/CS357861?source=search

    See if above article is related.

    Community Moderator
    July 12, 2024

    Hi @MP_10433217,

     

    I wanted to follow up with you on your post to see if your question has been answered. 
    If so, please mark the appropriate reply as the Accepted Solution. 
    Of course, if you have more to share on your issue, please let the Community know so that we can continue to help you. 

     

    Thanks,
    Anurag

    MP_1043321710-MarbleAuthorAnswer
    10-Marble
    September 20, 2024

    I have received below inputs from PTC to resolve this issue. We should not be modifying serialized class once we assign serialVersionUID

    .

    Root Cause:

    • If we do not define serialVersionUID in Java class, Java will give a default value and every change of the class will have a new value.
    • Then the serialized Java object created with old class will fail to deserialize with new class, because the difference of the serialVersionUID.

     

    The Best Practice as you did:

    • Always define serialVersionUID as 1
    • Never delete any attribute if change the class later, or else the Java object will be failed to deserialize, because the new class has no such attribute.