1 Reply Latest reply on Apr 10, 2005 11:12 AM by Ben Wang

    Error adding a cached object as an HttpSession attribute

    James Adams Novice

      I have some code in which I first fetch a cached HashMap from a TreeCacheAop using getObject(). I then wrap the HashMap as an object of another class which provides getters and setters to access the HashMap values. Next I add the object to an HttpSession as an attribute.

      The wrapper object's class is serializable and its only internal member is the HashMap (also serializable) which was fetched from the TreeCacheAop. The HashMap only contains Strings, Dates, and Integers, all of which are also serializable. However I'm getting a NotSerializableException from the CachedMapInterceptor whenever I reach the code where the object is being added to the HttpSession.

      Perhaps the dynamic proxy for the cached HashMap (returned by the TreeCacheAop.getObject() method) is not serializable, and hence can't be used within an object which is added as an attribute of an HttpSession?

      Below is the exception stack:

      16:16:59,706 INFO [STDOUT] java.io.NotSerializableException: org.jboss.cache.aop.CachedMapInterceptor
      16:16:59,706 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
      16:16:59,706 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      16:16:59,707 INFO [STDOUT] at java.util.ArrayList.writeObject(ArrayList.java:569)
      16:16:59,707 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      16:16:59,707 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
      16:16:59,707 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      16:16:59,707 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      16:16:59,708 INFO [STDOUT] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
      16:16:59,708 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
      16:16:59,708 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,708 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,708 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
      16:16:59,709 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,710 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      16:16:59,711 INFO [STDOUT] at java.util.HashMap.writeObject(HashMap.java:983)
      16:16:59,711 INFO [STDOUT] at sun.reflect.GeneratedMethodAccessor62.invoke(Unknown Source)
      16:16:59,711 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
      16:16:59,711 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:585)
      16:16:59,711 INFO [STDOUT] at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:890)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1333)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1369)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1341)
      16:16:59,712 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1284)
      16:16:59,713 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      16:16:59,713 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      16:16:59,713 INFO [STDOUT] at org.jboss.invocation.MarshalledValue.<init>(MarshalledValue.java:57)
      16:16:59,713 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.getMarshalledValue(JBossCacheService.java:419)
      16:16:59,713 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheService.putSession(JBossCacheService.java:99)
      16:16:59,713 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.SessionBasedClusteredSession.processSessionRepl(SessionBasedClusteredSession.java:149)
      16:16:59,714 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.processSessionRepl(JBossCacheManager.java:363)
      16:16:59,714 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.JBossCacheManager.storeSession(JBossCacheManager.java:213)
      16:16:59,714 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.InstantSnapshotManager.snapshot(InstantSnapshotManager.java:37)
      16:16:59,714 INFO [STDOUT] at org.jboss.web.tomcat.tc5.session.ClusteredSessionValve.invoke(ClusteredSessionValve.java:91)
      16:16:59,714 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      16:16:59,715 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      16:16:59,715 INFO [STDOUT] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
      16:16:59,715 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      16:16:59,715 INFO [STDOUT] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
      16:16:59,715 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
      16:16:59,716 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      16:16:59,716 INFO [STDOUT] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      16:16:59,716 INFO [STDOUT] at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
      16:16:59,716 INFO [STDOUT] at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
      16:16:59,716 INFO [STDOUT] at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
      16:16:59,716 INFO [STDOUT] at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
      16:16:59,717 INFO [STDOUT] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
      16:16:59,717 INFO [STDOUT] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
      16:16:59,717 INFO [STDOUT] at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
      16:16:59,717 INFO [STDOUT] at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
      16:16:59,717 INFO [STDOUT] at java.lang.Thread.run(Thread.java:595)
      



      Thanks in advance for any insight into this problem.


      --James