Hi Tonio,
Hmm. Method restoreAttachedState is for recreating Validator and
Listener objects that were serialized along with their attached
UIComponent. I can't see any custom validators or listeners in your JSP
snippet below, though. Perhaps you have some somewhere else?
In the 1.1.1 release of MyFaces, when server-side state saving was
enabled, no serialization of the view tree was done at all; the whole
tree was just put into the session unserialized. Of course when using
client-side state saving serialization *must* occur. And when clustering
or hot-deploy is enabled in the container, all objects in the session
need to be serializable.
In the SVN trunk code, serialization is always enabled unless
SERIALIZE_STATE_IN_SESSION is set to false in the web.xml file. You
might like to try setting this option to false and seeing if this fixes
your problem. Of course if it does, that means that your code will *not*
work if you ever enable hot-deploy or clustering as your http session
info cannot be saved to disk or transferred to other servers.
Alternatively, try enabling client-side state saving in your Sun RI
environment and see whether your code breaks. I suspect it will.
I suspect that the Sun RI works like MyFaces 1.1.1, ie doesn't bother to
serialize the view state on the server. This means that the fact that
your code isn't correctly serializable isn't actually noticed.
Regards,
Simon
Tonio Caputo wrote:
Hi everybody,
First of all, thank you very much.
One thing to remember, this application is actually running
correctly with Sun reference implementation, I'm not using
any of MyFaces particularities.
Here goes the full stack trace, and some code snippets:
java "Pages" are managed-beans with managed-scope -> Request.
-------------------------------------------------------------------
### - STACK TRACE
-------------------------------------------------------------------
2005-12-22 12:59:52 StandardWrapperValve[Faces Servlet]:
Servlet.service() for servlet Faces Servlet threw exception
java.lang.RuntimeException: Could not restore StateHolder of type
com.avivacanada.pampa.util.jsf.BasePageBean$1 (missing no-args
constructor?)
at
javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:655)
at
javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:641)
at
javax.faces.component.UIComponentBase.restoreState(UIComponentBase.java:696)
at javax.faces.component.UICommand.restoreState(UICommand.java:188)
at
javax.faces.component.html.HtmlCommandButton.restoreState(HtmlCommandButton.java:421)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:511)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
javax.faces.component.UIComponentBase.processRestoreState(UIComponentBase.java:502)
at
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreComponentState(JspStateManagerImpl.java:129)
at
org.apache.myfaces.application.jsp.JspStateManagerImpl.restoreView(JspStateManagerImpl.java:185)
at
org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:255)
at
org.apache.myfaces.lifecycle.LifecycleImpl.restoreView(LifecycleImpl.java:124)
at
org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:66)
at javax.faces.webapp.FacesServlet.service(FacesServlet.java:106)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardContextValve.java:198)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:152)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:137)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:118)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:104)
at
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:520)
at
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:929)
at
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:160)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:799)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:705)
at
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:577)
at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.lang.InstantiationException:
com.avivacanada.pampa.util.jsf.BasePageBean$1
at java.lang.Class.newInstance0(Class.java:293)
at java.lang.Class.newInstance(Class.java:261)
at
javax.faces.component.UIComponentBase.restoreAttachedState(UIComponentBase.java:651)
... 37 more
-------------------------------------------------------------------
### - JAVA CLASSES
-------------------------------------------------------------------
public class PageReferReason
extends BasePageBean
{
// =================================================================
// Components Definition
// =================================================================
private HtmlForm formMain = new HtmlForm();
.............
HtmlSelectOneMenu fCmbReferReason = new HtmlSelectOneMenu();
PmpLabel fLblVerbose = new PmpLabel();
HtmlInputTextarea fTaVerbose = new HtmlInputTextarea();
..........
UISelectItems itmReferReason = new UISelectItems();
public PageReferReason()
{
........
}
// =================================================================
// Getter and Setters
// =================================================================
// Combo/List items
public UISelectItems getItmReferReason() {
return itmReferReason;
}
public void setItmReferReason(UISelectItems pList) {
itmReferReason = pList;
}
// Page components
public HtmlForm getForm() {
return formMain;
}
public void setForm(HtmlForm pComp) {
formMain = pComp;
}
public HtmlSelectOneMenu getReferReason() {
return fCmbReferReason;
}
public void setReferReason(HtmlSelectOneMenu pComp) {
fCmbReferReason = pComp;
}
public PmpLabel getLblVerbose() {
return fLblVerbose;
}
public void setLblVerbose(PmpLabel pComp) {
fLblVerbose = pComp;
}
public HtmlInputTextarea getVerbose() {
return fTaVerbose;
}
public void setVerbose(HtmlInputTextarea pComp) {
fTaVerbose = pComp;
}
.................
}
public abstract class BasePageBean implements ItfControlledComp
{
public BasePageBean() {
...........
toolsActions();
}
...........
/** help option ================================== */
private HtmlCommandButton _fbtnMainHelpBtn = new HtmlCommandButton();
public HtmlCommandButton getMainHelpBtn()
{
return this._fbtnMainHelpBtn;
}
public void setMainHelpBtn(HtmlCommandButton pMainHelpBtn)
{
this._fbtnMainHelpBtn = pMainHelpBtn;
}
/** logout option ================================== */
private HtmlCommandButton _fbtnMainLogoutBtn =
new HtmlCommandButton();
public HtmlCommandButton getMainLogoutBtn()
{
return this._fbtnMainLogoutBtn;
}
public void setMainLogoutBtn(HtmlCommandButton pMainLogoutBtn)
{
this._fbtnMainLogoutBtn = pMainLogoutBtn;
}
...............................
public void toolsActions()
{
_fbtnMainLogoutBtn.addActionListener(new ActionListener()
{
public void processAction(ActionEvent e)
{
enqueueUG(new UserGesture(UserGesture.SIGN_OUT,this,null));
}
});
_fbtnMainHelpBtn.addActionListener(new ActionListener()
{
public void processAction(ActionEvent e)
{
enqueueUG(new UserGesture(UserGesture.HELP,this,null));
}
});
}
}
-------------------------------------------------------------------
### - JSP PAGE
-------------------------------------------------------------------
<f:view>
<html>
..............
<body>
<h:form onkeypress="return blockEnter(event);"
binding="#{PageReferReason.form}" id="form">
<div class="avivaLogo">
.................
<h:commandButton
binding="#{PageReferReason.mainLogoutBtn}"/>
.................
<h:commandButton binding="#{PageReferReason.mainHelpBtn}"/>
.................
</div>
<div class="mainDiv">
<!-- Combo: PageReferReason.referReason ====================-->
<h:selectOneMenu binding="#{PageReferReason.referReason}"
id="referReason">
<f:selectItems id="itmReferReason"
binding="#{PageReferReason.itmReferReason}"/>
</h:selectOneMenu>
<h:outputText binding="#{PageReferReason.lblVerbose}"
id="lblVerbose"/>
<h:inputTextarea binding="#{PageReferReason.verbose}"
id="verbose"/>
..........................
</div>
</h:form>
......
</body>
</html>
</f:view>