9 Replies Latest reply on Jun 3, 2008 1:24 PM by Stephen More

    HtmlToolBar can not be saved in session: Non-serializable at

    Stephen More Newbie

      I am currently building a org.richfaces.component.html.HtmlToolBar on a query from a database. The only way it will work is with a managed-bean-scope of request. When I try to use session scope I get:

      java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute

      How can I improve performance by caching the build of this tool bar ?

        • 2. Re: HtmlToolBar can not be saved in session: Non-serializabl
          Stephen More Newbie

          I am currently running this under tomcat 5.5 with facelets so I can use JSF RI 1.2

          • 3. Re: HtmlToolBar can not be saved in session: Non-serializabl
            Nick Belaevski Master

            I guess the problem is not in the component itself, but in the value of some attribute, that is not Serializable. Could you please provide page & beans code?

            • 4. Re: HtmlToolBar can not be saved in session: Non-serializabl
              Stephen More Newbie

              I have tried to make the code as small as possible and still exposes the stack trace

              <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
               "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
              
              <ui:composition template="/WEB-INF/layout/layout.xhtml"
               xmlns="http://www.w3.org/1999/xhtml"
               xmlns:a4j="http://richfaces.org/a4j"
               xmlns:rich="http://richfaces.org/rich"
               xmlns:ui="http://java.sun.com/jsf/facelets"
               xmlns:h="http://java.sun.com/jsf/html"
               xmlns:f="http://java.sun.com/jsf/core">
              
               <ui:define name="header">Header</ui:define>
              
               <ui:define name="content">
               <h:form>
               <rich:toolBar binding="#{richmenu.myBar}" />
               </h:form>
               </ui:define>
              
              </ui:composition>
              
              public class RichMenu
              {
               //private static org.slf4j.Logger _log = org.slf4j.LoggerFactory.getLogger( RichMenu.class );
              
               public void setMyBar( org.richfaces.component.html.HtmlToolBar bar )
               {
               //_log.trace( "Why is this needed ?" );
               }
              
               public org.richfaces.component.html.HtmlToolBar getMyBar()
               {
               //_log.trace( "Creating bar - START" );
               org.richfaces.component.html.HtmlToolBar bar = new org.richfaces.component.html.HtmlToolBar();
               bar.setItemSeparator( "line" );
              
               //_log.trace( "Creating bar - END" );
               return( bar );
               }
              
               /*
               public void onItemClick( javax.faces.event.ActionEvent event )
               {
               Object obj = event.getSource();
              
               if( obj instanceof org.richfaces.component.html.HtmlMenuItem )
               {
               org.richfaces.component.html.HtmlMenuItem item = (org.richfaces.component.html.HtmlMenuItem)obj;
               if( item != null )
               {
               _log.trace( "Clicked On: " + item.getValue().toString() );
               }
               }
               else
               {
               _log.trace( "unknown component: " + obj );
               }
               }
               */
              }
              
              2008-01-09 15:48:33,262 ERROR [[Faces Servlet]:250] Servlet.service() for servlet Faces Servlet threw exception
              java.lang.IllegalArgumentException: setAttribute: Non-serializable attribute
               at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1265)
               at org.apache.catalina.session.StandardSession.setAttribute(StandardSession.java:1243)
               at org.apache.catalina.session.StandardSessionFacade.setAttribute(StandardSessionFacade.java:130)
               at com.sun.faces.context.SessionMap.put(ExternalContextImpl.java:984)
               at com.sun.faces.mgbean.BeanManager$ScopeManager$SessionScopeHandler.handle(BeanManager.java:443)
               at com.sun.faces.mgbean.BeanManager$ScopeManager.pushToScope(BeanManager.java:418)
               at com.sun.faces.mgbean.BeanManager.createAndPush(BeanManager.java:370)
               at com.sun.faces.mgbean.BeanManager.create(BeanManager.java:222)
               at com.sun.faces.el.ManagedBeanELResolver.getValue(ManagedBeanELResolver.java:88)
               at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:135)
               at com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:73)
               at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:65)
               at com.sun.el.parser.AstValue.getValue(AstValue.java:106)
               at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:192)
               at com.sun.facelets.el.TagValueExpression.getValue(TagValueExpression.java:71)
               at com.sun.faces.application.ApplicationImpl.createComponent(ApplicationImpl.java:240)
               at com.sun.facelets.tag.jsf.ComponentHandler.createComponent(ComponentHandler.java:224)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:139)
               at com.sun.facelets.tag.jsf.ComponentHandler.applyNextHandler(ComponentHandler.java:314)
               at com.sun.facelets.tag.jsf.ComponentHandler.apply(ComponentHandler.java:169)
               at com.sun.facelets.tag.ui.DefineHandler.applyDefinition(DefineHandler.java:64)
               at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:128)
               at com.sun.facelets.impl.DefaultFaceletContext$TemplateManager.apply(DefaultFaceletContext.java:312)
               at com.sun.facelets.impl.DefaultFaceletContext.includeDefinition(DefaultFaceletContext.java:282)
               at com.sun.facelets.tag.ui.InsertHandler.apply(InsertHandler.java:68)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.tag.jsf.core.ViewHandler.apply(ViewHandler.java:109)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
               at com.sun.facelets.tag.CompositeFaceletHandler.apply(CompositeFaceletHandler.java:47)
               at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:248)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:294)
               at com.sun.facelets.impl.DefaultFacelet.include(DefaultFacelet.java:273)
               at com.sun.facelets.impl.DefaultFaceletContext.includeFacelet(DefaultFaceletContext.java:144)
               at com.sun.facelets.tag.ui.CompositionHandler.apply(CompositionHandler.java:113)
               at com.sun.facelets.compiler.NamespaceHandler.apply(NamespaceHandler.java:49)
               at com.sun.facelets.compiler.EncodingHandler.apply(EncodingHandler.java:25)
               at com.sun.facelets.impl.DefaultFacelet.apply(DefaultFacelet.java:95)
               at com.sun.facelets.FaceletViewHandler.buildView(FaceletViewHandler.java:509)
               at com.sun.facelets.FaceletViewHandler.renderView(FaceletViewHandler.java:552)
               at org.ajax4jsf.application.ViewHandlerWrapper.renderView(ViewHandlerWrapper.java:108)
               at org.ajax4jsf.application.AjaxViewHandler.renderView(AjaxViewHandler.java:216)
               at com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:110)
               at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
               at com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:139)
               at javax.faces.webapp.FacesServlet.service(FacesServlet.java:266)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
               at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
               at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
               at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
               at net.sourceforge.jams.JAMSFilter.doFilter(JAMSFilter.java:100)
               at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:215)
               at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
               at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
               at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
               at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
               at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
               at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:542)
               at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
               at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
               at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
               at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
               at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
               at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
               at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
               at java.lang.Thread.run(Thread.java:619)
              
              


              • 5. Re: HtmlToolBar can not be saved in session: Non-serializabl
                Stephen More Newbie

                Nick, can you reproduce this or do I need to supply more details ?

                • 6. Re: HtmlToolBar can not be saved in session: Non-serializabl
                  Stephen More Newbie

                  Should I open up a bug report on this ?

                  • 7. Re: HtmlToolBar can not be saved in session: Non-serializabl
                    Stephen More Newbie

                    The org.richfaces.component.html.HtmlToolBar cannot be saved in the session, but it CAN be saved in a cache.

                    By using OSCache my menu build time has decreased from 2 seconds to 2 miliseconds !



                    • 8. Re: HtmlToolBar can not be saved in session: Non-serializabl
                      Stephen More Newbie

                      I think this error is because < distributable /> is in the web.xml.

                      I am now seeing similar errors using fileUpload when distributable is turned on.

                      • 9. FIXED: HtmlToolBar can not be saved in session: Non-serializ
                        Stephen More Newbie

                        public class RichMenu

                        should become

                        public class RichMenu implements java.io.Serializable