I have a PersistenceCapable class
@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class MyClass
{
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Long id;
..........
..........
}
In my servlet, I need to store object of this class in session
............
MyClass u = new MyClass();
......
......
HttpSession session = req.getSession(true);
session.setAttribute("SV", u);
........
I am getting java.lang.RuntimeException: java.io.NotSerializableException:
What is this?
Sessions can be temporarily stored on disk or migrated to another application server. In order to make sure that objects in the session can be handled in those situations they need to be serailisable. You can flag this by implementing the
Serializableinterface: