Sastrija
Sastrija

Reputation: 3374

NotSerializableException on HashMap

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.

Upvotes: 1

Views: 6077

Answers (3)

Daniel Albert
Daniel Albert

Reputation: 757

The objects you store in the Map (in your case MyObj) should implement the interface java.io.Serializable

Upvotes: 6

mprabhat
mprabhat

Reputation: 20323

Your key is Integer which is Serializable by default. What is inside MyObj? I mean are there any objects inside MyObj?

Upvotes: 4

Hleb
Hleb

Reputation: 295

MyObj should implement java.io.Serializable.

Upvotes: 1

Related Questions