Storing DataObjects in Session

From: John Emmanuel (emmanuel.joh..mail.com)
Date: Fri May 09 2008 - 01:31:49 EDT

  • Next message: Andrus Adamchik: "Re: Storing DataObjects in Session"

    Hi,

    I would like to know if it is ok to store DataObjects in session.
    I stored an employee dataobject in session and it worked fine.
    however with every restart of tomcat java.io.NotSerializableException is
    thrown.
    am i doing something wrong. i am using cayenne 3.0m3 and here is the stack
    trace -

    May 9, 2008 10:46:17 AM org.apache.catalina.session.StandardManager doLoad
    SEVERE: IOException while loading persisted sessions:
    java.io.WriteAbortedException: writing aborted;
    java.io.NotSerializableException:
    org.apache.cayenne.cache.MapQueryCache$CacheEntry
    java.io.WriteAbortedException: writing aborted;
    java.io.NotSerializableException:
    org.apache.cayenne.cache.MapQueryCache$CacheEntry
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at
    org.apache.commons.collections.map.AbstractHashedMap.doReadObject(AbstractHashedMap.java:1210)
            at
    org.apache.commons.collections.map.LRUMap.doReadObject(LRUMap.java:388)
            at
    org.apache.commons.collections.map.LRUMap.readObject(LRUMap.java:372)
            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:1846)
            at
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
            at
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
            at
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
            at
    java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
            at
    org.apache.cayenne.access.DataContext.readObject(DataContext.java:1514)
            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:1846)
            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:1439)
            at
    org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:942)
            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.ContainerBase.setManager(ContainerBase.java:438)
            at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
            at
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
            at
    org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
            at
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
            at
    org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
            at
    org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
            at
    org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
            at
    org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
            at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
            at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
            at
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
            at
    org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
            at
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at
    org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
            at
    org.apache.catalina.core.StandardService.start(StandardService.java:516)
            at
    org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
            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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: java.io.NotSerializableException:
    org.apache.cayenne.cache.MapQueryCache$CacheEntry
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
            at
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at
    org.apache.commons.collections.map.AbstractHashedMap.doWriteObject(AbstractHashedMap.java:1180)
            at
    org.apache.commons.collections.map.LRUMap.doWriteObject(LRUMap.java:380)
            at
    org.apache.commons.collections.map.LRUMap.writeObject(LRUMap.java:364)
            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.invokeWriteObject(ObjectStreamClass.java:945)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at
    java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
            at
    org.apache.cayenne.access.DataContext.writeObject(DataContext.java:1484)
            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.invokeWriteObject(ObjectStreamClass.java:945)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at
    org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1515)
            at
    org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:959)
            at
    org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:517)
            at
    org.apache.catalina.session.StandardManager.unload(StandardManager.java:463)
            at
    org.apache.catalina.session.StandardManager.stop(StandardManager.java:667)
            at
    org.apache.catalina.core.StandardContext.stop(StandardContext.java:4512)
            at
    org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:924)
            at
    org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1189)
            at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1160)
            at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:313)
            at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
            at
    org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1086)
            at
    org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)
            at
    org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:448)
            at
    org.apache.catalina.core.StandardService.stop(StandardService.java:584)
            at
    org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)
            at org.apache.catalina.startup.Catalina.stop(Catalina.java:628)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:603)
            ... 6 more
    May 9, 2008 10:46:17 AM org.apache.catalina.session.StandardManager start
    SEVERE: Exception loading sessions from persistent storage
    java.io.WriteAbortedException: writing aborted;
    java.io.NotSerializableException:
    org.apache.cayenne.cache.MapQueryCache$CacheEntry
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1333)
            at java.io.ObjectInputStream.readObject(ObjectInputStream.java:351)
            at
    org.apache.commons.collections.map.AbstractHashedMap.doReadObject(AbstractHashedMap.java:1210)
            at
    org.apache.commons.collections.map.LRUMap.doReadObject(LRUMap.java:388)
            at
    org.apache.commons.collections.map.LRUMap.readObject(LRUMap.java:372)
            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:1846)
            at
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
            at
    java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1869)
            at
    java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1753)
            at
    java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1329)
            at
    java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1945)
            at
    java.io.ObjectInputStream.defaultReadObject(ObjectInputStream.java:480)
            at
    org.apache.cayenne.access.DataContext.readObject(DataContext.java:1514)
            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:1846)
            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:1439)
            at
    org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:942)
            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.ContainerBase.setManager(ContainerBase.java:438)
            at
    org.apache.catalina.core.StandardContext.start(StandardContext.java:4271)
            at
    org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:791)
            at
    org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:771)
            at
    org.apache.catalina.core.StandardHost.addChild(StandardHost.java:525)
            at
    org.apache.catalina.startup.HostConfig.deployDescriptor(HostConfig.java:626)
            at
    org.apache.catalina.startup.HostConfig.deployDescriptors(HostConfig.java:553)
            at
    org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:488)
            at
    org.apache.catalina.startup.HostConfig.start(HostConfig.java:1147)
            at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:311)
            at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
            at
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
            at
    org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
            at
    org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
            at
    org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
            at
    org.apache.catalina.core.StandardService.start(StandardService.java:516)
            at
    org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:578)
            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 org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
            at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
    Caused by: java.io.NotSerializableException:
    org.apache.cayenne.cache.MapQueryCache$CacheEntry
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1156)
            at
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at
    org.apache.commons.collections.map.AbstractHashedMap.doWriteObject(AbstractHashedMap.java:1180)
            at
    org.apache.commons.collections.map.LRUMap.doWriteObject(LRUMap.java:380)
            at
    org.apache.commons.collections.map.LRUMap.writeObject(LRUMap.java:364)
            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.invokeWriteObject(ObjectStreamClass.java:945)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509)
            at
    java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:416)
            at
    org.apache.cayenne.access.DataContext.writeObject(DataContext.java:1484)
            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.invokeWriteObject(ObjectStreamClass.java:945)
            at
    java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461)
            at
    java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392)
            at
    java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150)
            at
    java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326)
            at
    org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1515)
            at
    org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:959)
            at
    org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:517)
            at
    org.apache.catalina.session.StandardManager.unload(StandardManager.java:463)
            at
    org.apache.catalina.session.StandardManager.stop(StandardManager.java:667)
            at
    org.apache.catalina.core.StandardContext.stop(StandardContext.java:4512)
            at
    org.apache.catalina.core.ContainerBase.removeChild(ContainerBase.java:924)
            at
    org.apache.catalina.startup.HostConfig.undeployApps(HostConfig.java:1189)
            at org.apache.catalina.startup.HostConfig.stop(HostConfig.java:1160)
            at
    org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:313)
            at
    org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
            at
    org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1086)
            at
    org.apache.catalina.core.ContainerBase.stop(ContainerBase.java:1098)
            at
    org.apache.catalina.core.StandardEngine.stop(StandardEngine.java:448)
            at
    org.apache.catalina.core.StandardService.stop(StandardService.java:584)
            at
    org.apache.catalina.core.StandardServer.stop(StandardServer.java:744)
            at org.apache.catalina.startup.Catalina.stop(Catalina.java:628)
            at org.apache.catalina.startup.Catalina.start(Catalina.java:603)
            ... 6 more

    regards,
    John Emmanuel



    This archive was generated by hypermail 2.0.0 : Fri May 09 2008 - 01:32:32 EDT