- 博客分类:
- 异常
最近有几个项目组在使用spring http invoker调用SSO远程接口时,发现一个错误。
经调查,这个是由于SSO的hibernate版本和某些新项目的hibernate版本不一致造成。 很多人都会奇怪,远程接口调用跟hibernate有什么关系。
其实是这样的:
远程方法返回的复杂对象中包含了set, 这个set一般是hibernate一对多关系从数据库中load出来的。虽然这个set定义的是java.util.set接口, 但是其实实例是:org.hibernate.collection. PersistentSet.
我们看一下org.hibernate.collection. PersistentSet 这个类的定义:
。
所以说传到客户端的对象中,其实是包含了PersistentSet,当客户端进行反序列化的时候,由于hibernate版本不一致, 导致报org.hibernate.collection.AbstractPersistentCollection 错误。
- org.springframework.remoting.RemoteAccessException:
- Could not deserialize result from HTTP invoker remote service [http://192.168.180.15:8080/spring-http-invoker/httpservice/userInfoService];
- nested exception is java.io.InvalidClassException: org.hibernate.collection.AbstractPersistentCollection;
- 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 这个类的定义:
- public class PersistentSet extends AbstractPersistentCollection implements Set
所以说传到客户端的对象中,其实是包含了PersistentSet,当客户端进行反序列化的时候,由于hibernate版本不一致, 导致报org.hibernate.collection.AbstractPersistentCollection 错误。