11 Replies Latest reply on Mar 30, 2009 9:38 AM by nbelaevski

    RichFaces Ajax calls failed in cluster on failover

    fensminger

      Hello,

      My problem is :
      - Tomcat 6 in cluster configured with replicated session for failover.
      - A client is on one node and browse normaly.
      - The node on which is the client is stopped.
      - The AJAX call of the client failed when for example when he tries to sort a rich:datatable tag.

      However, if he tries to see a new page, the server responds a good page. So, the session seems to be correctly replicated.
      I add a filter to verify that my session is serilisable and it is ok.

      I think that RichFaces 3.3.0GA (ajax4jsf) has a problem to save its state.
      The implementation of JSF is MyFaces 1.2.6.
      Has anybody know this problem ? is it a bug ?

      Thanks,
      Frederic.

      Errors logs :

      javax.faces.FacesException: javax.crypto.BadPaddingException: Given final block not properly padded
       org.apache.myfaces.shared_impl.util.StateUtils.symmetric(StateUtils.java:373)
       org.apache.myfaces.shared_impl.util.StateUtils.symmetric(StateUtils.java:411)
       org.apache.myfaces.shared_impl.util.StateUtils.decrypt(StateUtils.java:291)
       org.apache.myfaces.shared_impl.util.StateUtils.reconstruct(StateUtils.java:240)
       org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getSavedState(HtmlResponseStateManager.java:187)
       org.apache.myfaces.renderkit.html.HtmlResponseStateManager.getTreeStructureToRestore(HtmlResponseStateManager.java:151)
       org.ajax4jsf.application.AjaxStateManager.restoreLogicalViewId(AjaxStateManager.java:573)
       org.ajax4jsf.application.AjaxStateManager.restoreStateFromSession(AjaxStateManager.java:454)
       org.ajax4jsf.application.AjaxStateManager.restoreView(AjaxStateManager.java:402)
       org.apache.myfaces.application.jsp.JspViewHandlerImpl.restoreView(JspViewHandlerImpl.java:515)
       com.ocpsoft.pretty.application.PrettyViewHandler.restoreView(PrettyViewHandler.java:93)
       com.sun.facelets.FaceletViewHandler.restoreView(FaceletViewHandler.java:316)
       org.ajax4jsf.application.ViewHandlerWrapper.restoreView(ViewHandlerWrapper.java:107)
       org.apache.myfaces.lifecycle.RestoreViewExecutor.execute(RestoreViewExecutor.java:85)
       org.apache.myfaces.lifecycle.LifecycleImpl.executePhase(LifecycleImpl.java:103)
       org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:76)
       javax.faces.webapp.FacesServlet.service(FacesServlet.java:151)
       org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
       org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
       org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:390)
       org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:359)
      


      Web.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <web-app
       id="LUXNEXT_ID"
       version="2.4"
       xmlns="http://java.sun.com/xml/ns/j2ee"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
      >
      
       <display-name>LUXNEXT</display-name>
      
      
       <context-param>
       <param-name>webAppRootKey</param-name>
       <param-value>luxnext.root</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
       <param-value>fr</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
       <param-value>lu.bourse.lxn.traduction.TraductionBundle</param-value>
       </context-param>
      
       <context-param>
       <param-name>log4jConfigLocation</param-name>
       <param-value>/WEB-INF/log4j.xml</param-value>
       </context-param>
      
       <context-param>
       <param-name>contextConfigLocation</param-name>
       <param-value>/WEB-INF/applicationContext.xml /WEB-INF/applicationContext-security.xml</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>luxnext</param-value>
       </context-param>
       <context-param>
       <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
       <param-value>com.sun.facelets.FaceletViewHandler</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.CONFIG_FILES</param-name>
       <param-value>/WEB-INF/faces-config-main.xml,/WEB-INF/fr/faces-config-nav.xml,/WEB-INF/en/faces-config-nav.xml</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
       <param-value>.xhtml</param-value>
       </context-param>
      
       <context-param>
       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
       <param-value>server</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.COMPRESS_STATE_IN_SESSION</param-name>
       <param-value>false</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
       <param-value>false</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.LIBRARIES</param-name>
       <param-value>/WEB-INF/taglib/jstl-core.taglib.xml;/WEB-INF/taglib/jstl-fn.taglib.xml;/WEB-INF/taglib/custom.taglib.xml;/WEB-INF/taglib/tomahawk.taglib.xml</param-value>
       </context-param>
      
       <context-param>
       <param-name>org.apache.myfaces.ERROR_HANDLING</param-name>
       <param-value>false</param-value>
       </context-param>
       <context-param>
       <param-name>facelets.DEVELOPMENT</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <!-- Optional JSF-RI Parameters to Help Debug -->
       <context-param>
       <param-name>com.sun.faces.validateXml</param-name>
       <param-value>true</param-value>
       </context-param>
       <context-param>
       <param-name>com.sun.faces.verifyObjects</param-name>
       <param-value>true</param-value>
       </context-param>
      
       <context-param>
       <param-name>facelets.REFRESH_PERIOD</param-name>
       <param-value>2</param-value>
       </context-param>
      
       <!-- Pour que IE6 ne bugge pas, il faut un Buffer size > 0 -->
       <context-param>
       <param-name>facelets.BUFFER_SIZE</param-name>
       <param-value>131072</param-value>
       </context-param>
      
       <!-- Leave the listener commented-out if using JBoss -->
       <listener>
       <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
       </listener>
      
       <listener>
       <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
       </listener>
      
       <listener>
       <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
       </listener>
      
       <listener>
       <listener-class>org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
       </listener>
      
       <listener>
       <listener-class>lu.bourse.lxn.commun.InitAppListener</listener-class>
       </listener>
      
       <filter>
       <filter-name>HttpSessionSizeFilter</filter-name>
       <filter-class>lu.bourse.lxn.commun.HttpSessionSizeFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>HttpSessionSizeFilter</filter-name>
       <url-pattern>*.xhtml</url-pattern>
       </filter-mapping>
      
       <filter>
       <filter-name>Pretty Filter</filter-name>
       <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>Pretty Filter</filter-name>
       <url-pattern>/fr/*</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>Pretty Filter</filter-name>
       <url-pattern>/en/*</url-pattern>
       </filter-mapping>
      
       <filter>
       <filter-name>LuxnextUrlFilter</filter-name>
       <filter-class>lu.bourse.lxn.commun.LuxnextUrlFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>LuxnextUrlFilter</filter-name>
       <url-pattern>*.html</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>LuxnextUrlFilter</filter-name>
       <url-pattern>*.xhtml</url-pattern>
       </filter-mapping>
      
       <filter>
       <filter-name>springSecurityFilterChain</filter-name>
       <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>springSecurityFilterChain</filter-name>
       <url-pattern>/*</url-pattern>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>REQUEST</dispatcher>
       </filter-mapping>
      
       <filter>
       <filter-name>RessourcesStaticFilter</filter-name>
       <filter-class>lu.bourse.lxn.commun.RessourcesStaticFilter</filter-class>
       </filter>
       <filter-mapping>
       <filter-name>RessourcesStaticFilter</filter-name>
       <url-pattern>/static_images/*</url-pattern>
       </filter-mapping>
       <filter-mapping>
       <filter-name>RessourcesStaticFilter</filter-name>
       <url-pattern>/static_docs/*</url-pattern>
       </filter-mapping>
      
       <filter>
       <display-name>RichFaces Filter</display-name>
       <filter-name>richfaces</filter-name>
       <filter-class>org.ajax4jsf.Filter</filter-class>
       <init-param>
       <param-name>forceparser</param-name>
       <param-value>false</param-value>
       </init-param>
       </filter>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
      
       <servlet>
       <servlet-name>Faces Servlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>Faces Servlet</servlet-name>
       <url-pattern>*.xhtml</url-pattern>
       </servlet-mapping>
      
       <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
       <init-param>
       <param-name>maxFileSize</param-name>
       <param-value>20m</param-value>
       </init-param>
      </filter>
      
      <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
      <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <!-- servlet-name must match the name of your javax.faces.webapp.FacesServlet entry -->
       <servlet-name>Faces Servlet</servlet-name>
      </filter-mapping>
      
      <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
      <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
      </filter-mapping>
      
       <session-config>
       <session-timeout>10</session-timeout>
       </session-config>
      
       <welcome-file-list>
       <!-- Redirects to "welcome.htm" for dispatcher handling -->
       <welcome-file>start.jsp</welcome-file>
       </welcome-file-list>
      
       <error-page>
       <exception-type>java.lang.Throwable</exception-type>
       <location>/templates/error.xhtml</location>
       </error-page>
      
       <error-page>
       <error-code>404</error-code>
       <location>/templates/error404.xhtml</location>
       </error-page>
      
       <error-page>
       <error-code>500</error-code>
       <location>/templates/error.xhtml</location>
       </error-page>
      
       <jsp-config>
       <jsp-property-group>
       <url-pattern>*.html</url-pattern>
       <page-encoding>ISO-8859-1</page-encoding>
       </jsp-property-group>
       </jsp-config>
      
      
      </web-app>
      



        • 1. Re: RichFaces Ajax calls failed in cluster on failover
          ilya_shaikovsky

           

           <context-param>
           <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
           <param-value>false</param-value>
           </context-param>
          


          should be true.

          https://jira.jboss.org/jira/browse/RF-3631

          • 2. Re: RichFaces Ajax calls failed in cluster on failover
            nbelaevski

            Hi Frederic,

            I suppose this is an issue caused by the way MyFaces is crypting saved state. Can you please check whether this problem is reproduced without RichFaces .jar files and filter mappings (you can use h:commandLink instead of a4j:commandLink)?

            • 3. Re: RichFaces Ajax calls failed in cluster on failover
              fensminger

              Hello,

              I change the code :

               <context-param>
               <param-name>org.apache.myfaces.SERIALIZE_STATE_IN_SESSION</param-name>
               <param-value>true</param-value>
               </context-param>
              


              The problem is the same.

              Effectively when I use only Myfaces, the replication of http session is ok.

              Does a workaround exist for MyFaces crypting state ? I thought that crypting state was only with Saving state on client. In my configuration Saving state is configured on server.

              Frederic.



              • 4. Re: RichFaces Ajax calls failed in cluster on failover
                nbelaevski

                Frederic,

                Try configuring key explicitly: http://wiki.apache.org/myfaces/Secure_Your_Application

                • 5. Re: RichFaces Ajax calls failed in cluster on failover
                  fensminger

                  Hello,

                  I try to secure my application, but the problem is the same.

                  I have no more idea to solve my problem.

                  Thanks,
                  Frederic

                  • 6. Re: RichFaces Ajax calls failed in cluster on failover
                    nbelaevski

                    Frederic,

                    I've checked the problem, MyFaces documentation seems to be incorrect, context parameter name should be org.apache.myfaces.SECRET and not org.apache.myfaces.secret. I've succesfully configured poll application switching seamlessly between cluster nodes on nodes failures under MyFaces 1.2.5.

                    Please add this and try:

                    <context-param>
                     <param-name>org.apache.myfaces.SECRET</param-name>
                     <param-value>NzY1NDMyMTA=</param-value>
                     </context-param>


                    • 7. Re: RichFaces Ajax calls failed in cluster on failover
                      fensminger

                      Hello,

                      It is effectively ok if saving state is client :

                       <context-param>
                       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                       <param-value>client</param-value>
                       </context-param>
                      


                      but the saving state server does not work for :
                       <context-param>
                       <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                       <param-value>server</param-value>
                       </context-param>
                      


                      Server saving state is the mode that I want to limit the size of the page.

                      Have an other idea ?

                      Thanks,
                      Frederic.


                      • 8. Re: RichFaces Ajax calls failed in cluster on failover
                        nbelaevski

                        Frederic,

                        I've tried with server-side state saving.

                        • 9. Re: RichFaces Ajax calls failed in cluster on failover
                          nbelaevski

                          For reference: my web.xml file

                          <?xml version="1.0" encoding="UTF-8"?>
                          <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
                           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                           xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
                           <display-name>Archetype Created Web Application</display-name>
                          
                           <context-param>
                           <param-name>org.apache.myfaces.SECRET</param-name>
                           <param-value>NzY1NDMyMTA=</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.richfaces.SKIN</param-name>
                           <param-value>#{skinBean.skin}</param-value>
                           </context-param>
                           <context-param>
                           <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
                           <param-value>server</param-value>
                           </context-param>
                          
                           <!--
                           context-param>
                           <param-name>com.sun.faces.externalizeJavaScript</param-name>
                           <param-value>true</param-value> </context-param
                           -->
                          
                           <!--
                           context-param>
                           <param-name>com.sun.faces.enableRestoreView11Compatibility</param-name>
                           <param-value>true</param-value> </context-param
                           -->
                          
                          
                           <context-param>
                           <param-name>org.richfaces.LoadStyleStrategy</param-name>
                           <param-value>DEFAULT</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.richfaces.LoadScriptStrategy</param-name>
                           <param-value>DEFAULT</param-value>
                           </context-param>
                          
                           <context-param>
                           <param-name>org.ajax4jsf.ENCRYPT_RESOURCE_DATA</param-name>
                           <param-value>false</param-value>
                           </context-param>
                          
                           <!--
                           <context-param> <param-name>org.ajax4jsf.xmlparser.ORDER</param-name>
                           <param-value>NONE</param-value> </context-param>
                           -->
                          
                           <context-param>
                           <param-name>com.sun.faces.numberOfLogicalViews</param-name>
                           <param-value>1</param-value>
                           </context-param>
                          
                           <context-param>
                           <param-name>org.ajax4jsf.COMPRESS_SCRIPT</param-name>
                           <param-value>false</param-value>
                           </context-param>
                           <context-param>
                           <param-name>org.ajax4jsf.COMPRESS_STYLE</param-name>
                           <param-value>true</param-value>
                           </context-param>
                           <!--
                           context-param> <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
                           <param-value>.xhtml</param-value> </context-param
                           -->
                           <context-param>
                           <param-name>facelets.DEVELOPMENT</param-name>
                           <param-value>true</param-value>
                           </context-param>
                           <context-param>
                           <param-name>facelets.SKIP_COMMENTS</param-name>
                           <param-value>true</param-value>
                           </context-param>
                           <context-param>
                           <param-name>facelets.VIEW_MAPPINGS</param-name>
                           <param-value>*.xhtml</param-value>
                           </context-param>
                          
                           <session-config>
                           <session-timeout>1000</session-timeout>
                           </session-config>
                          
                           <filter>
                           <display-name>RedirectFilter</display-name>
                           <filter-name>redirectFilter</filter-name>
                           <filter-class>RedirectFilter</filter-class>
                           </filter>
                          
                           <filter-mapping>
                           <filter-name>redirectFilter</filter-name>
                           <servlet-name>Faces Servlet</servlet-name>
                           <dispatcher>REQUEST</dispatcher>
                           <dispatcher>FORWARD</dispatcher>
                           <dispatcher>INCLUDE</dispatcher>
                           <dispatcher>ERROR</dispatcher>
                           </filter-mapping>
                          
                           <filter>
                           <display-name>RichFaces Filter</display-name>
                           <filter-name>richfaces</filter-name>
                           <filter-class>org.ajax4jsf.Filter</filter-class>
                           </filter>
                          
                           <filter-mapping>
                           <filter-name>richfaces</filter-name>
                           <servlet-name>Faces Servlet</servlet-name>
                           <dispatcher>REQUEST</dispatcher>
                           <dispatcher>FORWARD</dispatcher>
                           <dispatcher>INCLUDE</dispatcher>
                           <dispatcher>ERROR</dispatcher>
                           </filter-mapping>
                           <servlet>
                           <servlet-name>Faces Servlet</servlet-name>
                           <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                           <load-on-startup>1</load-on-startup>
                           </servlet>
                           <servlet-mapping>
                           <servlet-name>Faces Servlet</servlet-name>
                           <url-pattern>/faces/*</url-pattern>
                           </servlet-mapping>
                          
                           <error-page>
                           <exception-type>javax.faces.application.ViewExpiredException</exception-type>
                           <location>/faces/pages/calendar.jsp</location>
                           </error-page>
                          
                           <distributable />
                          
                          </web-app>


                          • 10. Re: RichFaces Ajax calls failed in cluster on failover
                            fensminger

                            Hello,

                            I do a little web application with Myfaces and Sun implementation of JSF :

                            http://www.neufgiga.com/n/50-17/share/LNK964149d082ce862bb/

                            I keep your web.xml, I only suppress this code :

                            <context-param>
                             <param-name>org.richfaces.SKIN</param-name>
                             <param-value>#{skinBean.skin}</param-value>
                             </context-param>
                             <filter>
                             <display-name>RedirectFilter</display-name>
                             <filter-name>redirectFilter</filter-name>
                             <filter-class>RedirectFilter</filter-class>
                             </filter>
                            
                             <filter-mapping>
                             <filter-name>redirectFilter</filter-name>
                             <servlet-name>Faces Servlet</servlet-name>
                             <dispatcher>REQUEST</dispatcher>
                             <dispatcher>FORWARD</dispatcher>
                             <dispatcher>INCLUDE</dispatcher>
                             <dispatcher>ERROR</dispatcher>
                             </filter-mapping>
                            


                            But, when I clic on ModalSessionAjax link on page2.jsp, the failover does not work.

                            Please, could you try my web application (see link above) to verify that I don't have a problem with my tomcat configuration ?
                            I put war files and eclipse projects.

                            Thanks a lot,
                            Frederic.

                            • 11. Re: RichFaces Ajax calls failed in cluster on failover
                              nbelaevski

                              Frederic,

                              Looks like a bug: https://jira.jboss.org/jira/browse/RF-6647.