This problem description matches my own experience.
It's hard to pin the blame entirely on StateHolderSaver because the JSF 2 version looks the same as the JSF 1.2 version.
But StateHolderSaver seems to have a bug that reveals itself in JSF 2.
The restore() method has this fragment:
// if the Object to save did not implement Serializable or
// StateHolder
if (className == null) {
return null;
}
The problem is the comment is not reflected in the implementation because className is not null if the object implements neither Serializable nor StateHolder (proposed fix bolded below):
public StateHolderSaver(FacesContext context, Object toSave) {
className = toSave.getClass().getName();
if (toSave instanceof StateHolder) {
// do not save an attached object that is marked transient.
if (!((StateHolder) toSave).isTransient()) {
savedState =
(Serializable) ((StateHolder) toSave).saveState(context);
} else {
className = null;
}
} else if (toSave instanceof Serializable) {
savedState = (Serializable) toSave;
className = null;
}[b] else {
className = null; /////////////// <<<<-------------------------- else clause added.
}[/b]
}
[Message sent by forum member 'hanafey']
http://forums.java.net/jive/thread.jspa?messageID=475714