It is cause by readResolve() that it cannot reference to the SessionFactory. The SessionFactory can be lookup inside Session Bean and no problem. For my intention, I am not going to reconnect the session in client side, but I want to keep the session-scope cached object and pass back to the server side and reconnect again at later use.
The remote interface is
Code:
public net.sf.hibernate.Session getSession( )
throws java.rmi.RemoteException;
Here is the exception during client deserialized the object
Code:
Caused by: java.io.InvalidObjectException: Could not find a SessionFactory named: java:/hibernate/HibernateFactory
at net.sf.hibernate.impl.SessionFactoryImpl.readResolve(SessionFactoryImpl.java:399)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeReadResolve(ObjectStreamClass.java:925)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1655)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1845)
at java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:452)
at net.sf.hibernate.impl.SessionImpl.readObject(SessionImpl.java:446)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:838)
at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1746)
at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1646)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1274)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:324)
at java.rmi.MarshalledObject.get(MarshalledObject.java:135)
at org.jboss.invocation.jrmp.interfaces.JRMPInvokerProxy.invoke(JRMPInvokerProxy.java:136)
at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:87)
at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:46)
at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:45)
at org.jboss.proxy.ejb.StatefulSessionInterceptor.invoke(StatefulSessionInterceptor.java:104)END
at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:85)