在 servlet 会话和 java.io.NotSerializableException 中保存对象 [英] Saving objects in servlet session and java.io.NotSerializableException

查看:45
本文介绍了在 servlet 会话和 java.io.NotSerializableException 中保存对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 SEVERE: IOException while loading persisted sessions:
         java.io.WriteAbortedException:
         writing aborted; java.io.NotSerializableException:

这意味着这个对象不能持久化在硬盘上.

That means this object cannot be persisted on hard disk.

这是否意味着将不实现Serializable"的 Session 对象保留在其中是不安全的?

Does it imply that it's not safe to keep in Session objects that do not implement "Serializable"?

我没有听说在 Session 对象中保存不可序列化的对象有限制.

I haven't heard that there are limitations on saving non-serializable objects in Session object.

这只是意味着 Tomcat 会一直将它们保存在内存中,对吗?

It simply means that Tomcat will always keep them in memory, right?

推荐答案

这是否意味着不安全保留在没有的 Session 对象中实现可序列化"?

Does it imply that it's not safe to keep in Session objects that do not implement "Serializable"?

完全正确,是的.

然而,如果它们实际上不需要进行任何序列化,许多 servlet 容器会让您摆脱它.

However, many servlet containers will let you get away with it, if they don't actually need to do any serialization.

例如,Tomcat 并不关心会话属性是否可序列化,除非您启用会话复制.它需要能够序列化属性以将它们复制到集群中的其他服务器.

For example, Tomcat doesn't care if the session attributes are serializable or not, unless you enable session replication. It needs to be able to serialize the attributes to replicate them to the other servers in the cluster.

在您的情况下,容器似乎正在尝试将会话数据持久保存到磁盘,这又需要序列化.

In your case, it seems that the container is trying to persist the session data to disk, which again would require serialization.

这篇关于在 servlet 会话和 java.io.NotSerializableException 中保存对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆