myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Robinson" <andrew.rw.robin...@gmail.com>
Subject Re: Why do managed beans must implement the Serializable interface
Date Wed, 23 May 2007 15:52:48 GMT
If you use component binding, make sure that the binding's scope is
request and not session. Bound components should not be
serialized/re-used across requests.

On 5/23/07, Trumml <Martin.Trummer@systema.info> wrote:
>
> Thanks for this short reply.
> But this serialization is a little bit problematic for me...
> I have a site with two different backing beans and a command button. The
> command button calls method A.1 from bean A, the site is reloaded (the
> method changes some properties of bean A) and all properties of A are
> renewed within the jsf site. Additionally A.1 changes some properties of
> bean B but those properties are not renewed within the view.
> So I tried to use component binding with bean B but this does not work
> because I can not use HtmlOutputText with my bean B because it is not
> serializable...?
>
> <h:commandButton value="action" action="#{A.1}" />
> <h:outputText value="#{A.property}"/>
> <h:outputText value="#{B.property}"/>
>
>
>
>
> Werner Punz-2 wrote:
> >
> > This has to be done due to the jsf inherent state saving and also some
> > app server serialize the sessions for clustering.
> >
> > Werner
> >
> >
> > Trumml schrieb:
> >> I use MyFaces (1.1.5) with Tomahawk and Facelet support. I added the
> >> following commmand to my xhtlm site:
> >> <h:commandButton value="doXY" action="#{PatientNavigatorBean.doXY}" />
> >> When I press this button an Exception is thrown because the
> >> PatientNavigatorBean is not serializable. My question is: which managed
> >> beans have to be serializable, when and why?
> >> When I add the Serializable interface to my managed bean everything works
> >> fine but I do want to know why I have to do this and are there possibly
> >> any
> >> fields in my bean which might be transient?
> >>
> >> => I already found a forum post but it does not contain the correct
> >> answer
> >> for my question i guess (
> >> http://www.nabble.com/What-requires-implementing-the-Serializable-interface--tf991035.html#a2566919
> >> http://www.nabble.com/What-requires-implementing-the-Serializable-interface--tf991035.html#a2566919
> >> )
> >>
> >> 16:16:37,983 ERROR [JspStateManagerImpl] Exiting serializeView - Could
> >> not
> >> serialize state: at.co.systema.ce.jsf.PatientNavigator
> >> java.io.NotSerializableException: at.co.systema.ce.jsf.PatientNavigator
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1081)
> >>         at
> >> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1375)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1347)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at java.util.ArrayList.writeObject(ArrayList.java:569)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at java.util.ArrayList.writeObject(ArrayList.java:569)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at java.util.HashMap.writeObject(HashMap.java:1039)
> >>         at sun.reflect.GeneratedMethodAccessor87.invoke(Unknown Source)
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at java.util.ArrayList.writeObject(ArrayList.java:569)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at java.util.ArrayList.writeObject(ArrayList.java:569)
> >>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>         at
> >> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>         at
> >> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>         at java.lang.reflect.Method.invoke(Method.java:585)
> >>         at
> >> java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:917)
> >>         at
> >> java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1339)
> >>         at
> >> java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1290)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1079)
> >>         at
> >> java.io.ObjectOutputStream.writeArray(ObjectOutputStream.java:1251)
> >>         at
> >> java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
> >>         at
> >> java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:302)
> >>         at
> >> org.apache.myfaces.application.jsp.JspStateManagerImpl.serializeView(JspStateManagerImpl.java:512)
> >>         at
> >> org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedViewInServletSession(JspStateManagerImpl.java:453)
> >>         at
> >> org.apache.myfaces.application.jsp.JspStateManagerImpl.saveSerializedView(JspStateManagerImpl.java:312)
> >>         at
> >> com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:594)
> >>         at
> >> org.apache.myfaces.lifecycle.RenderResponseExecutor.execute(RenderResponseExecutor.java:41)
> >>         at
> >> org.apache.myfaces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:132)
> >>         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:140)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> >>         at
> >> org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> >>         at
> >> org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:75)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
> >>         at
> >> org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
> >>         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.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:66)
> >>         at
> >> org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveContext.java:102)
> >>         at
> >> org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:162)
> >>         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.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:684)
> >>         at java.lang.Thread.run(Thread.java:595)
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Why-do-managed-beans-must-implement-the-Serializable-interface-tf3796802.html#a10766503
> Sent from the MyFaces - Users mailing list archive at Nabble.com.
>
>

Mime
View raw message