严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframewor

严重: IOException while loading persisted sessions: java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.security.web.firewall.RequestWrapper

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.security.web.firewall.RequestWrapper

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

        at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1588)

        at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1061)

        at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:284)

        at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)

        at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:470)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)

        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)

        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:620)

        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:303)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)

Caused by: java.io.NotSerializableException: org.springframework.security.web.firewall.RequestWrapper

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)

        at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1664)

        at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1078)

        at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:411)

        at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)

        at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:497)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5442)

        at java.lang.Thread.run(Thread.java:662)

        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5459)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1072)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1072)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:748)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.startup.Catalina.stop(Catalina.java:693)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:654)

        ... 6 more

2013-9-26 13:34:51 org.apache.catalina.session.StandardManager startInternal

严重: Exception loading sessions from persistent storage

java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: org.springframework.security.web.firewall.RequestWrapper

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1332)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1946)

        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1870)

        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1752)

        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1328)

        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)

        at org.apache.catalina.session.StandardSession.readObject(StandardSession.java:1588)

        at org.apache.catalina.session.StandardSession.readObjectData(StandardSession.java:1061)

        at org.apache.catalina.session.StandardManager.doLoad(StandardManager.java:284)

        at org.apache.catalina.session.StandardManager.load(StandardManager.java:204)

        at org.apache.catalina.session.StandardManager.startInternal(StandardManager.java:470)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5219)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)

        at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:774)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:1033)

        at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:291)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardService.startInternal(StandardService.java:443)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:727)

        at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:145)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:620)

        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:303)

        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:431)

Caused by: java.io.NotSerializableException: org.springframework.security.web.firewall.RequestWrapper

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1164)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1518)

        at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1483)

        at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1400)

        at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1158)

        at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:330)

        at org.apache.catalina.session.StandardSession.writeObject(StandardSession.java:1664)

        at org.apache.catalina.session.StandardSession.writeObjectData(StandardSession.java:1078)

        at org.apache.catalina.session.StandardManager.doUnload(StandardManager.java:411)

        at org.apache.catalina.session.StandardManager.unload(StandardManager.java:353)

        at org.apache.catalina.session.StandardManager.stopInternal(StandardManager.java:497)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardContext$4.run(StandardContext.java:5442)

        at java.lang.Thread.run(Thread.java:662)

        at org.apache.catalina.core.StandardContext.stopInternal(StandardContext.java:5459)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1072)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.ContainerBase.stopInternal(ContainerBase.java:1072)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardService.stopInternal(StandardService.java:502)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.core.StandardServer.stopInternal(StandardServer.java:748)

        at org.apache.catalina.util.LifecycleBase.stop(LifecycleBase.java:225)

        at org.apache.catalina.startup.Catalina.stop(Catalina.java:693)

        at org.apache.catalina.startup.Catalina.start(Catalina.java:654)

        ... 6 more

 

原理分析:(类未继承序列化接口)

Tomcat在内部实现的时候,会有一个机制,那就是当Tomcat服务器停止 后,tomcat会将内存中的信息写到硬盘上,当我们重启服务器的时候,他会将硬盘上序列化文件重新读入内存中,以此来保证session的共享,在集群系统中经常要使用。而在此,我们实际就是将session中存储的一个个对象序列化到硬盘,但是对象中如果有对象属性,我们也将这个对象序列化到硬盘,tomcat序列化一般在work目录下。但是不是所有的对象都可以被序列化的,他必须实现Serializable接口,也就是序列化,然后 java虚拟机在加载这个类的时候,对字节码会进行特殊处理,生成的二进制代码可以通过 ObjectOutputStream.writeObject(obj)方法写到硬盘上。而虽然我们FormBean实现了序列化接口,而对象属性对应 得类没有实现序列化接口,不能被序列化,最后导致以上异常。

 

解决办法一:

配置tomcat在关闭的时候就不去保存session资源。

在server.xml中Context下添加如下的内容:

<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>

再进行启动停止等操作,报如下的类似错误:

org.apache.catalina.session.PersistentManagerBase start 严重: No Store configured, persistence disabled

原因是添加的东东少添加了一点点儿。 解决办法:

修改刚才添加的 <Context>中<Manager> 元素: 将<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false"/>改为:

<Manager className="org.apache.catalina.session.PersistentManager" saveOnRestart="false">

  <Store className="org.apache.catalina.session.FileStore"/>

</Manager>

即可解决该问题。

解决办法二:

将那些需要放在session的类进行序列化。 也就是让类实现接口java.io.Serializable即可

 

另附:http://blog.csdn.net/qxs965266509/article/details/8808456

 

我们再来看所报的异常:java.io.WriteAbortedException: writing aborted;

【JDK API】public class WriteAbortedException extends ObjectStreamException

【描述】在写入操作过程中抛出 ObjectStreamException 之一的信号。在写入操作过程中抛出 ObjectStreamExceptions 之一时,在读取操作过程中将抛出此异常。终止写入的异常可在详细信息字段中找到。该流被重置为初始状态,而且对已经反序列化的对象的所有引用都被丢弃。

posted on 2013-09-26 20:11  道可道,非常道  阅读(4929)  评论(1编辑  收藏  举报