关于spring remoting支持,有四种方案: 1. 传统RMI.spring简化了RMI开发: JNDI没有启动时会自动启动/支持普通对象发布为RMI服务. 2. 基于http invoker.http+二进制序列化.缺点:不支持回调 3. 基于caucho的Hessian.http+二进制序列化. 4. 基于caucho的Burlap. http+xml序列化. 不过在burlap hession 中序列化延迟加载的hibernate对象时就会出现问题 因为它们在序列化对象时会试图加载所有的相关对象 此时session可能已关闭 而在反序列化po时,所有po的持久化状态都不能带过来 而是以默认的未持久化状态 所以你访问的时候 又会抛出Exception 现在知道什么原因引起的了,下面的工作就简单了,分别修改服务器端和客户端的代码 1.服务器端对延迟加载的对象直接以空对象代替 2.客户端把所有的po以普通对象或集合代替 以集合为例: CollectionSerializer.java package com.caucho.burlap.io; ...... public class CollectionSerializer extends Serializer { ...... public void writeObject(Object obj, AbstractBurlapOutput out) throws IOException { ..... if ((list instanceof PersistentCollection) && !((PersistentCollection) list).wasInitialized()) { log.warn("try to serialise not initialized collection :" + obj.getClass().getName() + "; filled null value"); out.writeListBegin(0, obj.getClass().getName()); out.writeListEnd(); } else { ....... CollectionDeserializer.java ...... public Object readList(AbstractBurlapInput in, int length) throws IOException { ...... else if (Collection.class.equals(_type)) list = new ArrayList(); else if (PersistentSet.class.equals(_type)){ log.debug("make a Arraylist for PersistentCollection"); list = new HashSet(); }else if (PersistentList.class.equals(_type)){ log.debug("make a Arraylist for PersistentCollection"); list = new ArrayList(); } ...... | |