关于spring http invoker中一个常见错误,dubbo 调用 hibernate的set map list

来源:互联网 发布:生态环境监测大数据 编辑:程序博客网 时间:2024/06/06 10:05


    博客分类: 
  • 异常
org.springframework.remoting.RemoteAccessExceptionnested exception is java.io.InvalidClassExceptionorg.hibernate.collection.AbstractPersistentCollection
最近有几个项目组在使用spring http invoker调用SSO远程接口时,发现一个错误。 
Java代码  收藏代码
  1. org.springframework.remoting.RemoteAccessException:   
  2. Could not deserialize result from HTTP invoker remote service [http://192.168.180.15:8080/spring-http-invoker/httpservice/userInfoService];  
  3. nested exception is java.io.InvalidClassException: org.hibernate.collection.AbstractPersistentCollection;   
  4. local class incompatible: stream classdesc serialVersionUID = -7982170513654570219, local class serialVersionUID = -5723701046347946317  

        经调查,这个是由于SSO的hibernate版本和某些新项目的hibernate版本不一致造成。 很多人都会奇怪,远程接口调用跟hibernate有什么关系。 
         其实是这样的: 
         远程方法返回的复杂对象中包含了set,  这个set一般是hibernate一对多关系从数据库中load出来的。虽然这个set定义的是java.util.set接口, 但是其实实例是:org.hibernate.collection. PersistentSet. 
        我们看一下org.hibernate.collection. PersistentSet 这个类的定义:
Java代码  收藏代码
  1. public class PersistentSet extends AbstractPersistentCollection  implements Set  
。 
         所以说传到客户端的对象中,其实是包含了PersistentSet,当客户端进行反序列化的时候,由于hibernate版本不一致, 导致报org.hibernate.collection.AbstractPersistentCollection 错误。 
0 0
原创粉丝点击