Tomcat 抛出 Cannot serialize session attribute 异常
2012-05-16 23:40
441 查看
今天team成员遇到个很奇怪的问题,在启动和关闭Tomcat 6时, 抛出如下异常:Cannot serialize session attribute XXX for 。我很是纳闷,到apache官网查看了下,发现tomcat 会试图 serialize存在的session资源. 如果 sessions中相关的对象没有实现 serializable 接口, 就会出现Cannot serialize session attribute XXX for 异常。由于开始对某个类实现了Serializable接口,启动了tomcat,然后又取消实现Serializable接口,重启tomcat就报错了。原文如下:
Because when you shutdown tomcat, it tries to serial all objects within
the session scope. The
class you are referring to
'org.apache.commons.fileupload.DeferredFileOutputStream' does not
implement 'java.io.Serializable' and therefore tomcat throws this
exception when trying to serialize it.
Whilst I don't know what the class
'org.apache.catalina.session.StandardManager' does, presumably is
performs a check to see if an object stored within the session is
serializable before trying to
write it disk, or it might remove non-serializable object from the
session scope on shutdown.
如果你不想看到该异常, 也不想保存session. 那么你可以在项目部署描述文件中(如. test.xml,)(instead of just exploding the war) 的 <Context> tags中间 加上 :
<Manager className="org.apache.catalina.session.PersistentManager"
saveOnRestart="false"/>这样 tomcat 在关闭的时候就不会保存session资源了.你也可以在server.xml中指定上面的值. 这也所有的程序都使用这个设置了.
Because when you shutdown tomcat, it tries to serial all objects within
the session scope. The
class you are referring to
'org.apache.commons.fileupload.DeferredFileOutputStream' does not
implement 'java.io.Serializable' and therefore tomcat throws this
exception when trying to serialize it.
Whilst I don't know what the class
'org.apache.catalina.session.StandardManager' does, presumably is
performs a check to see if an object stored within the session is
serializable before trying to
write it disk, or it might remove non-serializable object from the
session scope on shutdown.
如果你不想看到该异常, 也不想保存session. 那么你可以在项目部署描述文件中(如. test.xml,)(instead of just exploding the war) 的 <Context> tags中间 加上 :
<Manager className="org.apache.catalina.session.PersistentManager"
saveOnRestart="false"/>这样 tomcat 在关闭的时候就不会保存session资源了.你也可以在server.xml中指定上面的值. 这也所有的程序都使用这个设置了.
相关文章推荐
- Tomcat 问题: Cannot serialize session attribute XXX for ..的解决办法
- Cannot serialize session attribute indexView for session
- tomcat抛出异常:java.lang.RuntimeException: Cannot register non aspect
- 启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099;
- linux下安装tomcat,启动抛出异常
- 启动tomcat 时错误: 代理抛出异常错误: java.rmi.server.ExportException: Port already in use: 1099;
- 启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099的解决办法
- 打包war包部署到Tomcat。调用接口时,pad端提示:连接服务器异常。但后台无任何异常抛出
- linux 上tomcat 服务器抛出socket异常“文件打开太多”的问题 - 也碰到了这个问题,解决方案如下
- tomcat抛出的奇怪异常
- 在Hibernate 4.3中如果使用了@Table注解,在获取session的时候会抛出如下异常解决办法
- tomcat8.5基础 web.xml 抛出指定异常时,转到指定的页面
- tomcat异常: Cannot get a connection, pool exhausted
- 启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099的解决办法
- 启动tomcat时 错误: 代理抛出异常 : java.rmi.server.ExportException: Port already in use: 1099的解决办法
- 在Android M及更高版本中使用 Settings.System 抛出异常"You cannot keep your settings in the secure settings. "
- linux tomcat 服务器抛出socket异常 Too many open files 的问题
- cannot expose session attribute '_from_source' because of an existing model object of the same name