When I access a specific page of my Wicket application, I get a NotSerializableException:
java.io.NotSerializableException: my.package.MyPanel$1
But I can't explain why wicket should try to serialize the Panel. Any idea?
I don't know if it helps, but here is the code I use to add the panel:
final User profileUser = ...;
final IModel<User> loggedInUser = ...;
add(new MyPanel("panelid", new Model<MyObject>(new MyObject()))
{
@Override
public boolean isVisible()
{
return profileUser != null && profileUser.equals(loggedInUser.getObject());
}
});
Wicket serializes many things into the session as part of its approach to dealing with clustering.
Just about everything in Wicket (eventually) extends
Component
which implementsIClusterable
which extendsSerializable
. So components such as panels that created in Wicket need to be serializable.A common practice is to create
LoadableDetachableModel
classes wrapping your normal business objects with logic that stores only a key in session and reloads using that key.If you use such models as fields in your components instead of the full business objects you'll strain the session memory much less.