6 Replies Latest reply on May 29, 2009 3:07 PM by henry katz

    Richfaces fileupload FAQ (1.76) breaks Hibernate layer

    henry katz Newbie

      Hi,

      The FAQ for the fileupload widget

      http://www.jboss.org/file-access/default/members/jbossrichfaces/freezone/docs/devguide/en/faq/faq.html#richfileUploadforMyFaces


      requires that the servlet-mapping pattern for the Faces Servlet
      be *.jsf and not *.faces.

      This breaks the hibernate layer completely, in our case as the
      hibernate filter requires *.faces:

      <filter-mapping>
       <filter-name>hibernateFilter</filter-name>
       <url-pattern>*.faces</url-pattern>
      </filter-mapping>


      What hack do I need to make (other than changing our hibernatefilter
      pattern - we came first) to get the fileupload widget to work with *.jsf?

      Thanks,
      Henry

        • 1. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
          Nick Belaevski Master

          Hi Henry,

          How is Faces servlet mapped?

          • 2. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
            henry katz Newbie

            Like this:

             <!-- Faces Servlet Mapping -->
            <servlet-mapping>
             <servlet-name>FacesServlet</servlet-name>
             <url-pattern>*.jsf</url-pattern>
            </servlet-mapping>
            


            Please see below for relevant excerpts from web.xml:

             <filter>
             <filter-name>RichFacesFilter</filter-name>
             <filter-class>org.ajax4jsf.Filter</filter-class>
             <init-param>
             <param-name>createTempFiles</param-name>
             <param-value>true</param-value>
             </init-param>
            </filter>
            
            <filter>
             <filter-name>ExtensionsFilter</filter-name>
             <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
             <init-param>
             <param-name>uploadMaxFileSize</param-name>
             <param-value>100m</param-value>
             </init-param>
             <init-param>
             <param-name>uploadThresholdSize</param-name>
             <param-value>100k</param-value>
             </init-param>
            </filter>
            
            <filter>
             <filter-name>filterChainProxy</filter-name>
             <filter-class>
             org.springframework.web.filter.DelegatingFilterProxy
             </filter-class>
             <init-param>
             <param-name>targetBean</param-name>
             <param-value>filterChainProxy</param-value>
             </init-param>
            </filter>
            <filter>
             <filter-name>hibernateFilter</filter-name>
             <filter-class>
             org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
             </filter-class>
            </filter>
            <filter>
             <filter-name>dwrFilter</filter-name>
             <filter-class>
             org.directwebremoting.faces.FacesExtensionFilter
             </filter-class>
            </filter>
            <filter>
             <filter-name>JSFUnitFilter</filter-name>
             <filter-class>org.jboss.jsfunit.framework.JSFUnitFilter</filter-class>
            </filter>
            
             <filter-mapping>
             <filter-name>RichFacesFilter</filter-name>
             <servlet-name>FacesServlet</servlet-name>
             <dispatcher>REQUEST</dispatcher>
             <dispatcher>FORWARD</dispatcher>
             <dispatcher>INCLUDE</dispatcher>
             <dispatcher>ERROR</dispatcher>
            </filter-mapping>
            <filter-mapping>
             <filter-name>ExtensionsFilter</filter-name>
             <servlet-name>FacesServlet</servlet-name>
            </filter-mapping>
            <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.) -->
            <filter-mapping>
             <filter-name>ExtensionsFilter</filter-name>
             <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
            </filter-mapping>
            
            <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
            <filter-mapping>
             <filter-name>ExtensionsFilter</filter-name>
             <servlet-name>FacesServlet</servlet-name>
             <!-- url-pattern>*.jsf</url-pattern -->
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>ExtensionsFilter</filter-name>
             <url-pattern>*.jsf</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>filterChainProxy</filter-name>
             <url-pattern>/*</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>hibernateFilter</filter-name>
             <url-pattern>*.jsf</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>hibernateFilter</filter-name>
             <url-pattern>/ServletTestRunner</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>hibernateFilter</filter-name>
             <url-pattern>/ServletRedirector</url-pattern>
            </filter-mapping>
            
            <filter>
             <filter-name>DwrFacesFilter</filter-name>
             <filter-class>org.directwebremoting.faces.FacesExtensionFilter</filter-class>
            </filter>
            
            <filter-mapping>
             <filter-name>hibernateFilter</filter-name>
             <url-pattern>/dwr/*</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>DwrFacesFilter</filter-name>
             <url-pattern>/dwr/*</url-pattern>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>JSFUnitFilter</filter-name>
             <servlet-name>ServletTestRunner</servlet-name>
            </filter-mapping>
            
            <filter-mapping>
             <filter-name>JSFUnitFilter</filter-name>
             <servlet-name>ServletRedirector</servlet-name>
            </filter-mapping>
            
             <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.springframework.security.ui.session.HttpSessionEventPublisher</listener-class>
            </listener>
            <listener>
             <listener-class>com.sandp.cre.web.listener.CreHttpSessionListener</listener-class>
            </listener>
            
             <!-- Faces Servlet -->
            <servlet>
             <servlet-name>FacesServlet</servlet-name>
             <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
             <load-on-startup>1</load-on-startup>
            </servlet>
            <servlet>
             <servlet-name>DwrServlet</servlet-name>
             <servlet-class>org.directwebremoting.servlet.DwrServlet</servlet-class>
             <init-param>
             <param-name>debug</param-name>
             <param-value>true</param-value>
             </init-param>
            </servlet>
            <servlet>
             <servlet-name>ServletRedirector</servlet-name>
             <servlet-class>org.jboss.jsfunit.framework.JSFUnitServletRedirector</servlet-class>
            </servlet>
            <servlet>
             <servlet-name>ServletTestRunner</servlet-name>
             <servlet-class>org.apache.cactus.server.runner.ServletTestRunner</servlet-class>
            </servlet>
            
             <!-- Faces Servlet Mapping -->
            <servlet-mapping>
             <servlet-name>FacesServlet</servlet-name>
             <url-pattern>*.jsf</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
             <servlet-name>DwrServlet</servlet-name>
             <url-pattern>/dwr/*</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
             <servlet-name>ServletRedirector</servlet-name>
             <url-pattern>/ServletRedirector</url-pattern>
            </servlet-mapping>
            <servlet-mapping>
             <servlet-name>ServletTestRunner</servlet-name>
             <url-pattern>/ServletTestRunner</url-pattern>
            </servlet-mapping>
            


            My inspiration was that by mapping all requests to be of a *.jsf pattern,
            Hibernate would be ok - which it was but then I got the doDecode()
            exception back in FileUploadRendererBase.java.

            Thanks,
            Henry

            • 3. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
              Nick Belaevski Master

              I see it's mapped twice:

              <filter-mapping>
               <filter-name>ExtensionsFilter</filter-name>
               <servlet-name>FacesServlet</servlet-name>
              </filter-mapping>
              <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)
               -->
              <filter-mapping>
               <filter-name>ExtensionsFilter</filter-name>
               <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
              </filter-mapping>
              
              <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
              <filter-mapping>
               <filter-name>ExtensionsFilter</filter-name>
               <servlet-name>FacesServlet</servlet-name>
               <!-- url-pattern>*.jsf</url-pattern -->
              </filter-mapping>

              Could this be the reason?

              • 4. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
                henry katz Newbie

                Hi,

                Yes - that allows the upload to work by reducing it to the following:

                <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <servlet-name>FacesServlet</servlet-name>
                </filter-mapping>
                <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)
                 -->
                <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
                </filter-mapping>
                


                The question remains still - why must we use the *.jsf pattern for the servlet-mapping? I would like to return all of them back to *.faces.

                Thanks,
                Henry

                "nbelaevski" wrote:
                I see it's mapped twice:
                <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <servlet-name>FacesServlet</servlet-name>
                </filter-mapping>
                <!-- extension mapping for serving page-independent resources (javascript, stylesheets, images, etc.)
                 -->
                <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <url-pattern>/faces/myFacesExtensionResource/*</url-pattern>
                </filter-mapping>
                
                <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
                <filter-mapping>
                 <filter-name>ExtensionsFilter</filter-name>
                 <servlet-name>FacesServlet</servlet-name>
                 <!-- url-pattern>*.jsf</url-pattern -->
                </filter-mapping>

                Could this be the reason?


                • 5. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
                  Nick Belaevski Master

                  You can use *.faces, see: https://jira.jboss.org/jira/browse/RF-7289.
                  The only thing important for this issue is that RF filter has to be run first. Here is what Servlet spec. says:

                  The order the container uses in building the chain of filters to be applied for a
                  particular request URI is as follows:
                  1. First, the <url-pattern> matching filter mappings in the same order that these
                  elements appear in the deployment descriptor.
                  2. Next, the <servlet-name> matching filter mappings in the same order that
                  these elements appear in the deployment descriptor.


                  • 6. Re: Richfaces fileupload FAQ (1.76) breaks Hibernate layer
                    henry katz Newbie

                    Nick,

                    Thanks for opening the JIRA. Yes, *.faces does indeed work!

                    Cheers,
                    Henry