HashMap 上的 NotSerializedException
我有一个哈希图,例如: Map gen = HashMap
当我执行 AccessController.doPrivileged(gen)
时,它会抛出异常,如下所示。谁能帮我解决这个问题。
java.security.PrivilegedActionException: java.io.NotSerializableException: java.util.HashMap
at java.security.AccessController.doPrivileged(Native Method)...
此代码在 Weblogic
环境中执行。
I've a hash map like :Map gen = HashMap<Integer, MyObj>
When I execute AccessController.doPrivileged(gen)
, it throws exception as follows. Can anyone help me on this.
java.security.PrivilegedActionException: java.io.NotSerializableException: java.util.HashMap
at java.security.AccessController.doPrivileged(Native Method)...
This code is getting executed in Weblogic
environment.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您存储在
Map
中的对象(在您的情况下是MyObj
)应该实现接口java.io.Serialized
The objects you store in the
Map
(in your caseMyObj
) should implement the interfacejava.io.Serializable
您的密钥是
Integer
,默认情况下是Serializable
。MyObj
里面有什么?我的意思是MyObj
中有任何对象吗?Your key is
Integer
which isSerializable
by default. What is insideMyObj
? I mean are there any objects insideMyObj
?MyObj 应该实现 java.io.Serializable。
MyObj should implement java.io.Serializable.