5 Replies Latest reply on Sep 10, 2008 3:19 AM by Andrei Markavtsov

    fileupload listener not called

    Steve Roy Newbie

      Hello,

      We are finding the listener method is not called for richfaces 3.2.2. We have applied the known documented fixes of upgrading JSF to JSF 1.2_07 and turning off the MyFaces the CHECK_EXTENSIONS_FILTER.

      Are there any other known workarounds?

      - steve

        • 1. Re: fileupload listener not called
          Andrei Markavtsov Apprentice

          Please your web.xml here.

          • 2. Re: fileupload listener not called
            Steve Roy Newbie

            Andre,

            Thank you for the follow up. We've tried in two separate web applications. I'll post both in case it helps.

            <?xml version="1.0"?>
            <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>a4jEchoText</display-name>

            <context-param>
            <param-name>org.richfaces.SKIN</param-name>
            <param-value>blueSky</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.CHECK_EXTENSIONS_FILTER</param-name>
            <param-value>false</param-value>
            </context-param>


            <display-name>RichFaces Filter</display-name>
            <filter-name>richfaces</filter-name>
            <filter-class>org.ajax4jsf.Filter</filter-class>
            <init-param>
            <param-name>createTempFiles</param-name>
            <param-value>false</param-value>
            </init-param>
            <init-param>
            <param-name>maxRequestSize</param-name>
            <param-value>1000000000</param-value>
            </init-param>



            <display-name>Sleep Filter</display-name>
            <filter-name>sleepFilter</filter-name>
            <filter-class>demo.SleepFilter</filter-class>



            <filter-name>MyFacesExtensionsFilter</filter-name>
            <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>



            <filter-mapping>
            <filter-name>richfaces</filter-name>
            <servlet-name>Faces Servlet</servlet-name>
            REQUEST
            FORWARD
            INCLUDE
            </filter-mapping>
            <filter-mapping>
            <filter-name>sleepFilter</filter-name>
            <servlet-name>Faces Servlet</servlet-name>
            REQUEST
            FORWARD
            INCLUDE
            ERROR
            </filter-mapping>
            <filter-mapping>
            <filter-name>MyFacesExtensionsFilter</filter-name>
            <url-pattern>*.jsf</url-pattern>
            </filter-mapping>


            <listener-class>com.sun.faces.config.ConfigureListener</listener-class>


            <!-- Faces Servlet -->

            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>1</load-on-startup>


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

            <login-config>
            <auth-method>BASIC</auth-method>
            </login-config>
            </web-app>


            <?xml version="1.0" encoding="UTF-8"?>
            <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
            xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
            xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
            http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

            <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.DEFAULT_SUFFIX</param-name>
            <param-value>.xhtml</param-value>
            </context-param>

            <context-param>
            <param-name>facelets.LIBRARIES</param-name>
            <param-value>
            /WEB-INF/tomahawk.taglib.xml; /WEB-INF/idexx-facelets.taglib.xml
            </param-value>
            </context-param>

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

            <context-param>
            <param-name>org.richfaces.SKIN</param-name>
            <param-value>telerexx</param-value>
            </context-param>


            <listener-class>
            org.jboss.seam.servlet.SeamListener
            </listener-class>



            <filter-name>Seam Filter</filter-name>
            <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
            <init-param>
            <param-name>createTempFiles</param-name>
            <param-value>true</param-value>
            </init-param>
            <init-param>
            <param-name>maxRequestSize</param-name>
            <param-value>200000</param-value>
            </init-param>



            <display-name>Sleep Filter</display-name>
            <filter-name>sleepFilter</filter-name>
            <filter-class>com.idexx.web.jsf.component.richfaces.fileupload.SleepFilter</filter-class>



            <filter-name>MyFacesExtensionsFilter</filter-name>
            <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>


            <filter-mapping>
            <filter-name>Seam Filter</filter-name>
            <url-pattern>*.jsf</url-pattern>
            </filter-mapping>

            <filter-mapping>
            <filter-name>sleepFilter</filter-name>
            <servlet-name>Faces Servlet</servlet-name>
            REQUEST
            FORWARD
            INCLUDE
            ERROR
            </filter-mapping>


            <filter-mapping>
            <filter-name>MyFacesExtensionsFilter</filter-name>
            <url-pattern>*.jsf</url-pattern>
            </filter-mapping>



            <servlet-name>Faces Servlet</servlet-name>
            <servlet-class>
            com.idexx.web.framework.servlet.CustomFacesServlet
            </servlet-class>
            <init-param>
            <param-name>errorPage</param-name>
            <param-value>/common/error/error.jsp</param-value>
            </init-param>
            <load-on-startup>1</load-on-startup>



            <servlet-name>Seam Resource Servlet</servlet-name>
            <servlet-class>
            org.jboss.seam.servlet.SeamResourceServlet
            </servlet-class>



            <servlet-name>Faces Servlet_tmp</servlet-name>
            <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
            <load-on-startup>0</load-on-startup>


            <servlet-mapping>
            <servlet-name>Seam Resource Servlet</servlet-name>
            <url-pattern>/seam/resource/*</url-pattern>
            </servlet-mapping>

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

            </web-app>


            • 3. Re: fileupload listener not called
              Andrei Markavtsov Apprentice

              Just change mapping for extension filter.

              This:

              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <url-pattern>*.jsf</url-pattern>
              </filter-mapping>


              Replace on:

              <filter-mapping>
              <filter-name>MyFacesExtensionsFilter</filter-name>
              <servlet-name>Faces Servlet</servlet-name>
              </filter-mapping>
              


              in both web.xml.


              • 4. Re: fileupload listener not called
                Steve Roy Newbie


                That did work. Thank you.

                Would you have a brief explanation as to why using the servlet-name vs the url-pattern affects the servlet processing?

                - steve

                • 5. Re: fileupload listener not called
                  Andrei Markavtsov Apprentice

                  It's extremely important to configure filters to be invoked in the following order: AJAX filter, then Extension filter.

                  If Extension filter mapped to file extension and AJAX filter mapped to servlet then Extension filter processes at the first in spite of definition order in web.xml.

                  So, we should keep the same definition order in web.xml (AJAX, Extension) and define the same mapping for filters.