7 Replies Latest reply on Jun 9, 2009 6:53 AM by nimo stephan

    rich:fileUpload and Seams s:fileUpload

    nimo stephan Master

      I have questions about fileUpload in Seam and Richfaces:

      1. Where lies the main differences of rich:fileUpload and Seams s:fileUpload?
      For example, s:fileUpload uses <h:form enctype="multipart/form-data">.
      Why does Richfaces not need a multipart-filter? Would it be better not using such a filter? Why?

      2.When should I use s:fileUpload instead of rich:fileUpload, and vice versa?

      3. Using Seam and rich:fileUpload, I can configure this in web.xml:

      <filter>
       <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>
       </filter>


      Or this in components.xml:

      <web:multipart-filter create-temp-files="true" max-request-size="200000" url-pattern="*.seam"/>


      Can I omit the configuration of createTempFiles, maxRequestSize in web.xml when I define it in components.xml?
      Richfaces does not use a multipart-filter, am I right?


      4. rich:fileUpload is ajax-based (or flash-based, if activated). When should I set allowFlash="true" instead of allowFlash="false"?

      5. Why can I not configure maxRequestSize and createTempFiles as properties in rich:fileUpload?

      for example:

      <rich:fileUpload maxRequestSize="100000" createTempFiles ="true"/>


        • 1. Re: rich:fileUpload and Seams s:fileUpload
          Nick Belaevski Master

          1. Multipart filter is built into RF filter, so it's there and used.

          2. Just put them side by side and see the difference :)

          3. Yes, you can omit. See #1

          4. Set allowFlash="true" when you clients have Flash installed

          5. Because that is configured for filter

          • 2. Re: rich:fileUpload and Seams s:fileUpload
            nimo stephan Master

            Hello,

            I get this error, when uploading huge files: (no error occurs, if the uploaded file-size is approx. 5 KB):

            12:06:11,781 WARN [ExceptionFilter] handling uncaught exception
            java.lang.NullPointerException
             at org.ajax4jsf.request.MultipartRequest.readData(MultipartRequest.java:468)
             at org.ajax4jsf.request.MultipartRequest.readNext(MultipartRequest.java:428)
             at org.ajax4jsf.request.MultipartRequest.getParam(MultipartRequest.java:807)
             at org.ajax4jsf.request.MultipartRequest.getParameter(MultipartRequest.java:870)
             at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:158)
             at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:43)
             at org.apache.myfaces.trinidadinternal.context.external.ServletRequestParameterMap.getAttribute(ServletRequestParameterMap.java:31)
             at org.apache.myfaces.trinidadinternal.context.external.AbstractAttributeMap.get(AbstractAttributeMap.java:73)
             at org.apache.myfaces.trinidadinternal.renderkit.core.CoreRenderKit.isPartialRequest(CoreRenderKit.java:163)
             at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:150)
             at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
             at org.jboss.seam.web.IdentityFilter.doFilter(IdentityFilter.java:40)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:90)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.web.ExceptionFilter.doFilter(ExceptionFilter.java:64)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.web.RedirectFilter.doFilter(RedirectFilter.java:45)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:178)
             at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)
             at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:347)
             at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)
             at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:56)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.web.LoggingFilter.doFilter(LoggingFilter.java:58)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.web.HotDeployFilter.doFilter(HotDeployFilter.java:53)
             at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
             at org.jboss.seam.servlet.SeamFilter.doFilter(SeamFilter.java:158)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
             at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
             at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
             at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
             at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
             at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
             at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
             at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
             at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
             at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:157)
             at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
             at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:262)
             at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
             at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
             at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)
             at java.lang.Thread.run(Unknown Source)
            12:06:11,781 WARN [ExceptionFilter] exception root cause
            12:06:11,781 WARN [ExceptionFilter] running exception handlers


            When SEAM starts, the log says:

            12:15:55,500 INFO [Initialization] done initializing Seam
            12:15:55,500 INFO [STDOUT] ServletListener is ready
            12:15:55,515 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.hotDeployFilter
            12:15:55,515 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.loggingFilter
            12:15:55,515 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.ajax4jsfFilter
            12:15:55,546 INFO [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
            12:15:55,546 INFO [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {org.richfaces.CONTROL_SKINNING=disable, org.apache.myfaces.trinidadinternal.DISABLE_CONTENT_COMPRESSION=true, org.apache.myfaces.trinidad.CACHE_VIEW_ROOT=false, org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER=com.sun.facelets.FaceletViewHandler, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, org.richfaces.LoadStyleStrategy=DEFAULT, org.richfaces.LoadScriptStrategy=DEFAULT, org.richfaces.CONTROL_SKINNING_CLASSES=disable, facelets.SKIP_COMMENTS=false, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml, javax.faces.STATE_SAVING_METHOD=server}
            12:15:55,546 INFO [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
            12:15:55,578 INFO [CacheManager] Selected [org.ajax4jsf.cache.LRUMapCacheFactory] cache factory
            12:15:55,578 INFO [LRUMapCacheFactory] Creating LRUMap cache instance using parameters: {org.richfaces.CONTROL_SKINNING=disable, org.apache.myfaces.trinidadinternal.DISABLE_CONTENT_COMPRESSION=true, org.apache.myfaces.trinidad.CACHE_VIEW_ROOT=false, org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER=com.sun.facelets.FaceletViewHandler, com.sun.faces.injectionProvider=org.jboss.web.jsf.integration.injection.JBossInjectionProvider, org.richfaces.LoadStyleStrategy=DEFAULT, org.richfaces.LoadScriptStrategy=DEFAULT, org.richfaces.CONTROL_SKINNING_CLASSES=disable, facelets.SKIP_COMMENTS=false, facelets.DEVELOPMENT=true, org.richfaces.SKIN=blueSky, javax.faces.DEFAULT_SUFFIX=.xhtml, javax.faces.STATE_SAVING_METHOD=server}
            12:15:55,578 INFO [LRUMapCacheFactory] Creating LRUMap cache instance of default capacity
            12:15:55,578 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.redirectFilter
            12:15:55,578 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.exceptionFilter
            12:15:55,578 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.multipartFilter
            12:15:55,578 INFO [SeamFilter] Initializing filter: org.jboss.seam.web.identityFilter


            So you see, org.jboss.seam.web.multipartFilter is installed, as I put the SEAM filter in web.xml:

            <filter>
             <filter-name>Seam Filter</filter-name>
             <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
             <!-- already configured in components.xml -->
             <init-param>
             <param-name>createTempFiles</param-name>
             <param-value>false</param-value>
             </init-param>
             </filter>


            What is wrong?


            • 3. Re: rich:fileUpload and Seams s:fileUpload
              nimo stephan Master

              I use RF 3.3.1, SEAM 2.1.1.

              • 4. Re: rich:fileUpload and Seams s:fileUpload
                Ilya Shaikovsky Master

                please show your web.xml configuration. And which JSF version used?

                • 5. Re: rich:fileUpload and Seams s:fileUpload
                  nimo stephan Master

                  I use JSF 1.2.

                  My web.xml:

                  hello,

                  JSF 1.2.

                  My web.xml:

                  <?xml version="1.0"?>
                  <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">
                   <!-- RichFaces -->
                   <context-param>
                   <param-name>org.richfaces.SKIN</param-name>
                   <param-value>blueSky</param-value>
                   </context-param>
                   <!-- Suppress spurious stylesheets -->
                   <context-param>
                   <param-name>org.richfaces.CONTROL_SKINNING</param-name>
                   <param-value>disable</param-value>
                   </context-param>
                   <context-param>
                   <param-name>org.richfaces.CONTROL_SKINNING_CLASSES</param-name>
                   <param-value>disable</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>facelets.DEVELOPMENT</param-name>
                   <param-value>true</param-value>
                   </context-param>
                   <context-param>
                   <param-name>facelets.SKIP_COMMENTS</param-name>
                   <param-value>false</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>
                  
                   <!-- Trinidad -->
                   <context-param>
                   <param-name>org.apache.myfaces.trinidad.ALTERNATE_VIEW_HANDLER</param-name>
                   <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                   </context-param>
                   <!--
                   <context-param>
                   <param-name>org.ajax4jsf.xmlparser.NEKO</param-name>
                   <param-value>*.seam</param-value>
                   </context-param>
                  
                  
                   <filter-mapping>
                   <filter-name>Trinidad</filter-name>
                   <servlet-name>faces</servlet-name>
                   </filter-mapping>
                   -->
                   <context-param>
                   <param-name>org.apache.myfaces.trinidad.CACHE_VIEW_ROOT</param-name>
                   <param-value>false</param-value>
                   </context-param>
                   <context-param>
                   <param-name>org.apache.myfaces.trinidadinternal.DISABLE_CONTENT_COMPRESSION</param-name>
                   <param-value>true</param-value>
                   </context-param>
                  
                  
                   <!-- Filter -->
                   <filter>
                   <filter-name>Seam Filter</filter-name>
                   <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>
                   <!-- already configured in components.xml -->
                   <init-param>
                   <param-name>createTempFiles</param-name>
                   <param-value>false</param-value>
                   </init-param>
                   <init-param>
                   <param-name>maxRequestSize</param-name>
                   <param-value>2147483647</param-value>
                   </init-param>
                   </filter>
                   <filter>
                   <filter-name>Trinidad</filter-name>
                   <filter-class>org.apache.myfaces.trinidad.webapp.TrinidadFilter</filter-class>
                   </filter>
                   <filter-mapping>
                   <filter-name>Seam Filter</filter-name>
                   <url-pattern>/*</url-pattern>
                   </filter-mapping>
                   <filter-mapping>
                   <filter-name>Trinidad</filter-name>
                   <url-pattern>*.seam</url-pattern>
                   <!--
                   <dispatcher>REQUEST</dispatcher>
                   <dispatcher>FORWARD</dispatcher>
                   <dispatcher>INCLUDE</dispatcher>
                   -->
                   </filter-mapping>
                   <!-- Listeners -->
                   <listener>
                   <listener-class>org.jboss.seam.servlet.SeamListener</listener-class>
                   </listener>
                   <listener>
                   <listener-class>com.actor.applicationScope.ApplicationManager</listener-class>
                   </listener>
                   <listener>
                   <listener-class>com.actor.listeners.ServletListener</listener-class>
                   </listener>
                   <servlet>
                   <servlet-name>Seam Resource Servlet</servlet-name>
                   <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>
                   </servlet>
                   <servlet>
                   <servlet-name>Faces Servlet</servlet-name>
                   <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
                   <load-on-startup>1</load-on-startup>
                   </servlet>
                   <servlet>
                   <servlet-name>Trinidad Resources</servlet-name>
                   <servlet-class>org.apache.myfaces.trinidad.webapp.ResourceServlet</servlet-class>
                   </servlet>
                   <!-- for PDF -->
                   <servlet>
                   <servlet-name>Document Store Servlet</servlet-name>
                   <servlet-class>org.jboss.seam.document.DocumentStoreServlet</servlet-class>
                   </servlet>
                   <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>*.seam</url-pattern>
                   </servlet-mapping>
                   <servlet-mapping>
                   <servlet-name>Trinidad Resources</servlet-name>
                   <url-pattern>/adf/*</url-pattern>
                   </servlet-mapping>
                   <servlet-mapping>
                   <servlet-name>Document Store Servlet</servlet-name>
                   <url-pattern>*.pdf</url-pattern>
                   </servlet-mapping>
                   <!-- Content Servlet -->
                   <session-config>
                   <session-timeout>20</session-timeout>
                   </session-config>
                   <login-config>
                   <auth-method>BASIC</auth-method>
                   </login-config>
                   <!--
                   <security-constraint>
                   <display-name>Restrict raw XHTML Documents</display-name>
                   <web-resource-collection>
                   <web-resource-name>XHTML</web-resource-name>
                   <url-pattern>*.xhtml</url-pattern>
                   </web-resource-collection>
                   <auth-constraint/>
                   </security-constraint>
                   -->
                  </web-app>


                  • 7. Re: rich:fileUpload and Seams s:fileUpload
                    nimo stephan Master

                    I found my failure. I have to set:

                    createTempFiles to "true", when dealing with large files:

                    <init-param>
                     <param-name>createTempFiles</param-name>
                     <param-value>true</param-value>
                     </init-param>



                    Now, no error occurs!