Ah... yeah, I never did get a chance to explain this in the documentation.

Currently what needs to happen before serialization can happen is that
the object must be fully loaded.  You can currently achieve this by
simply calling equals() or hashCode() (both also require the object to
be fully loaded to generate an accurate hashcode or perform a deep
equals).

The reason is that serializing across a  network boundary will cause
the lazy loading to fail if you attempted to do it on a different VM
or even the same VM after serialization and deserialization.  iBATIS
doesn't currently support "disconnection" of lazy loaders.

This isn't ideal, but I'm not sure if there's a better solution for
this case.  If you're going to serialize the result objects, then yes,
disable lazy loading.

Cheers,
Clinton

On Tue, May 4, 2010 at 6:33 AM, moffit <mof...@gmail.com> wrote:
>
> Hi Clinton,
>
>  The exception (thrown by Tomcat) is:
>
> 07:26:05,621 ERROR apache.catalina.session.ManagerBase - Exception loading
> sessions from persistent storage
> java.io.WriteAbortedException: writing aborted;
> java.io.NotSerializableException:
> org.apache.ibatis.executor.loader.ResultLoaderMap$LoadPair
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
>        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
>        at java.util.HashMap.readObject(HashMap.java:1030)
>        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:597)
>        at 
> java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:974)
>        at 
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1849)
>        at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
>        at 
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
>        at 
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
>        at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
>        at 
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
>        at 
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
>        at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
>        at 
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
>        at 
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
>        at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
>        at 
> java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1947)
>        at 
> java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1871)
>        at
> java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
>        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
>        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
>        at
> org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1470)
>        at
> org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:972)
>        at
> org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:394)
>        at
> org.apache.catalina.session.StandardManager.load(StandardManager.java:321)
>        at
> org.apache.catalina.session.StandardManager.start(StandardManager.java:637)
>        at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4476)
>        at
> org.apache.catalina.core.StandardContext.reload(StandardContext.java:3228)
>        at
> org.apache.catalina.manager.ManagerServlet.reload(ManagerServlet.java:918)
>        at
> org.apache.catalina.manager.HTMLManagerServlet.reload(HTMLManagerServlet.java:544)
>        at
> org.apache.catalina.manager.HTMLManagerServlet.doGet(HTMLManagerServlet.java:121)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:617)
>        at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
>        at
> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
>        at
> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
>        at
> org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
>        at
> org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
>        at
> org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
>        at
> org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
>        at
> org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
>        at
> org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
>        at
> org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
>        at
> org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
>        at 
> org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
>        at java.lang.Thread.run(Thread.java:619)
>
> I am using the ibatis-core-3.0.jar version of the library.
>
> Thanks,
>
> Mike
>
>
> Clinton Begin wrote:
>>
>> iBATIS 3 enhanced objects should be serializable.  Can you post the
>> exception you're getting?
>>
>> Clinton
>>
>> On Mon, May 3, 2010 at 7:25 PM, moffit <mof...@gmail.com> wrote:
>>>
>>> Hi,
>>>
>>>  I noticed that this question was asked a few years ago with Ibatis 2.X
>>> without any resolution.
>>>
>>>  Basically, lazy loaded objects are enhanced with byte-code generation.
>>> The enhanced object/proxy is not serializable even though the source
>>> object
>>> is.  This obviously plays havoc with web applications if the source
>>> object
>>> is stored in the session.  A very simple and probably often used scenario
>>> would be a user object that contains a contact object which contains a
>>> location, etc.., stored in the session after authentication.  Lazy
>>> loading
>>> can be very useful in situations like this, but the session cannot be
>>> serialized to disk by the container (e.g. Tomcat).  This negates
>>> clustering,
>>> for one, thing, and is also a pain for development, as the context is
>>> often
>>> reloaded due to code changes.  Without the serialization support, the
>>> developer must plow through the entire log on and resulting work-flow to
>>> get
>>> to the required web page again.
>>>
>>> Are there any technical or architectural issues around making the
>>> enhanced
>>> object serializable?  Has anyone else run into this problem?  Right now,
>>> I've disabled lazy loading to allow the session to be serialized.
>>>
>>> Thanks,
>>>
>>> Mike
>>> --
>>> View this message in context:
>>> http://old.nabble.com/Ibatis-3---Lazy-Loading-and-Serializable-Sessions-tp28442042p28442042.html
>>> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
>>> For additional commands, e-mail: user-java-h...@ibatis.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
>> For additional commands, e-mail: user-java-h...@ibatis.apache.org
>>
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/Ibatis-3---Lazy-Loading-and-Serializable-Sessions-tp28442042p28446761.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
> For additional commands, e-mail: user-java-h...@ibatis.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-java-unsubscr...@ibatis.apache.org
For additional commands, e-mail: user-java-h...@ibatis.apache.org

Reply via email to