Tomcat - 防止会话持久化

时间:2014-07-24 04:52:53

标签: java session tomcat

重启tomcat时出现IOException。 我尝试了exception loading sessions from persistent storage

中建议的各种解决方案

他们都没有解决问题。 我尝试取消注释context.xml中的<Manager pathname=""/>。没有帮助。

建议的另一个解决方案是使类实现Serialiable。我不想那样做。

我的目标是让Tomcat坚持这些会话。 我正在使用Tomcat 7.0.54。

以下是堆栈跟踪。请帮忙。

`SEVERE: IOException while loading persisted sessions:
     java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException:     com.comp.cloud.portal.zCompHD
     java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.comp.cloud.portal.zCompHD
     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1354)
     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
     at java.util.LinkedList.readObject(LinkedList.java:1136)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:606)
     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
     at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1990)
     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1915)
     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
     at java.io.ObjectInputStream.readObject(ObjectInputStream.java:370)
     at java.util.HashMap.readObject(HashMap.java:1183)
     at sun.reflect.GeneratedMethodAccessor18.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
     at java.lang.reflect.Method.invoke(Method.java:606)
     at java.io.ObjectStreamClass.invokeReadObject(ObjectStreamClass.java:1017)
     at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1893)
     at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1798)
     at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1350)
     at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1619)
     at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1084)
     at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:282)
     at org.apache.catalina.session.StandardManager.load(StandardManager.java:202)
     at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:489)
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5476)
     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
     at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
     at java.util.concurrent.FutureTask.run(FutureTask.java:262)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
     at java.lang.Thread.run(Thread.java:744)

1 个答案:

答案 0 :(得分:0)

解决此问题的另一种方法可能是使用Spring Session,它提供了一个可以以可配置方式持久化的替换HttpSession对象。可以使用各种持久性方法,例如, Redis,JDBC或内存映射。默认情况下,他们(或至少其中一些)可能希望项目可序列化,但实现更加可定制,因此您可以设置一个序列化程序来剥离不可序列化的对象,剩下的就是其余的(例如)。