webtier@glassfish.java.net

JSF 2: State restore causes InstantiationException

From: <webtier_at_javadesktop.org>
Date: Thu, 17 Jun 2010 02:19:08 PDT

Hello,

I have migrated from JSF 1.2 to 2.0. In my app I have a managed bean in application scope which holds references to some immutable objects of the class named SearchCategory. SearchCategory only has a few final variables which are set via constructor parameters. In fact SearchCategory does not have a zero-parameter constructor. Now, when validation fails for the view where SearchCategory instances are shown the second request results in a InstantiationException because StateHolderSaver calls Class#newInstance(). And as I said before SearchCategory does not provide a zero-parameter constructor. Isn't it a bug that StateHolderSaver relies on classes having a zero-parameter constructor? In JSF 1.2 I was just fine without this zero-parameter constructor. Are there any guidelines for classes potentially being saved and restored by JSF? If yes, where are these documented/specified? Has this something to do with the new partial state saving mechanism?

Kind regards,
R.
[Message sent by forum member 'robsta10']

http://forums.java.net/jive/thread.jspa?messageID=474633