java.io.InvalidClassException解決


報錯現象

Oops: JPAQueryException
An unexpected error occured caused by exception JPAQueryException: Error while executing query select t from TurnedIn t, Notification n  where n.itemId=t.id and n.type=? and n.receiver.id=? and n.isDeleted=false group by t order by t.createTime desc: org.hibernate.type.SerializationException: could not deserialize
...
Caused by: java.io.InvalidClassException: models.member.Member; local class incompatible: stream classdesc serialVersionUID = 8996579512119659486, local class serialVersionUID = -7513555048418418149

異常原因

本地和遠程的member序列化后的serialVersionUID不

解決方法

將本地的序列化的類中的版本號(serialVersionUID )改成和遠程中一樣,在本地的序列化類里的private static final long serialVersionUID =  改成遠程的就行了,如果沒有的話就加上這句。

 

關於“org.hibernate.type.SerializationException: could not deserialize”,我查了很多的資料,大概有以下幾個原因:

1.該類的序列版本號與從流中讀取的類描述符的版本號不匹配(jdk版本更換會造成這個問題)

2.該類包含未知數據類型(hibernate配置文件中未指定數據類型)

3.該類沒有可訪問的無參數構造方法


 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM