java.io.InvalidClassException解決

來源:互聯網
上載者:User

報錯現象

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.該類沒有可訪問的無參數構造方法

 

 

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.