2 Replies Latest reply on Feb 9, 2009 10:05 PM by Felipe Regalgo

    Richfaces - <rich:fileUpload>

    Felipe Regalgo Newbie

      Hi,

      I´m using JSF 1.2 + RichFaces 3.3 + Tomahawk 1.1.6 + Facelets

      All works very fine, less the rich:fileUpload component

      my xhtml is like:

      -------------------------------

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      
      <html xmlns="http://www.w3.org/1999/xhtml"
       xmlns:h="http://java.sun.com/jsf/html"
       xmlns:f="http://java.sun.com/jsf/core"
       xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:rich="http://richfaces.org/rich">
      
      <ui:composition template="/pages/template/template.xhtml">
      <ui:define name="conteudo">
      
      <h:form>
       <rich:fileUpload maxFilesQuantity="5" immediateUpload="true" fileUploadListener="#{modelAdminImportMB.listener}" />
      </h:form>
      </ui:define>
      </ui:composition>
      
      </html>


      -------------------------------

      When pages load the component render ok, but when I select a file and start make a upload a exception occur:


      Feb 8, 2009 6:23:44 AM com.sun.faces.lifecycle.Phase doPhase
      SEVERE: JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View ID: /admin/config/models/importModels.xhtml) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@2013eaab]
      06:23:44,093 ERROR BaseXMLFilter:181 - Exception in the filter chain
      javax.servlet.ServletException
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       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:387)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at code.filter.LoginFilter.doFilter(LoginFilter.java:24)
       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:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:139)
       at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
       at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
       at javax.faces.component.UIInput.decode(UIInput.java:725)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)
       at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
       at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:392)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
       at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       ... 24 more
      Feb 8, 2009 6:23:44 AM org.apache.catalina.core.StandardWrapperValve invoke
      SEVERE: Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:139)
       at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
       at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:789)
       at javax.faces.component.UIInput.decode(UIInput.java:725)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)
       at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
       at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:392)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:238)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:409)
       at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
       at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:100)
       at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:265)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       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:387)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:517)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:301)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at code.filter.LoginFilter.doFilter(LoginFilter.java:24)
       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:233)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
       at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
       at java.lang.Thread.run(Thread.java:619)





      my ManagedBean has the listener method

      public void listener(UploadEvent event) {
       System.out.println("ModelAdminImportMB.listener()");
      }



      and my web.xml is:


      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_ID" 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">
       <display-name>RecordCompare</display-name>
       <!-- FACELETS -->
       <context-param>
       <param-name>facelets.REFRESH_PERIOD</param-name>
       <param-value>2</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>facelets.DEVELOPMENT</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>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>
       <!-- RICH FACES -->
       <context-param>
       <param-name>org.richfaces.SKIN</param-name>
       <param-value>compare</param-value>
       </context-param>
       <!-- TOMAHAWK -->
       <filter>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
       <init-param>
       <description>Set the size limit for uploaded files.
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB</description>
       <param-name>uploadMaxFileSize</param-name>
       <param-value>1g</param-value>
       </init-param>
       <init-param>
       <description>Set the threshold size - files
       below this limit are stored in memory, files above
       this limit are stored on disk.
      
       Format: 10 - 10 bytes
       10k - 10 KB
       10m - 10 MB
       1g - 1 GB</description>
       <param-name>uploadThresholdSize</param-name>
       <param-value>100m</param-value>
       </init-param>
       <!--
       <init-param>
       <param-name>uploadRepositoryPath</param-name>
       <param-value>/temp</param-value>
       <description>Set the path where the intermediary files will be stored.
       </description>
       </init-param>
       -->
       </filter>
       <filter>
       <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>10485760</param-value>
       </init-param>
      
       </filter>
       <!-- LOGIN -->
       <filter>
       <filter-name>LoginFilter</filter-name>
       <filter-class>code.filter.LoginFilter</filter-class>
       </filter>
       <!-- extension mapping for adding <script/>, <link/>, and other resource tags to JSF-pages -->
       <filter-mapping>
       <filter-name>MyFacesExtensionsFilter</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </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>
       <filter-mapping>
       <filter-name>richfaces</filter-name>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <filter-mapping>
       <filter-name>LoginFilter</filter-name>
       <url-pattern>/*</url-pattern>
       </filter-mapping>
       <listener>
       <listener-class>code.listener.ListenerDeInicializacao</listener-class>
       </listener>
       <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>*.jsf</url-pattern>
       </servlet-mapping>
       <session-config>
       <session-timeout>240</session-timeout>
       </session-config>
       <welcome-file-list>
       <welcome-file>index.jsp</welcome-file>
       </welcome-file-list>
       <login-config>
       <auth-method>BASIC</auth-method>
       </login-config>
      </web-app>



      So, All things works very fine, include Tomahawk´s upload, but unfortunatly Richfaces upload not!

      someone could help me!?

      thanks


        • 1. Re: Richfaces - <rich:fileUpload>
          Andrei Markavtsov Apprentice

          Hi,

          Richfaces filter should be defined firstly before Extension filter definition.

          See FAQ how to adjust fileupload under myfaces here

          • 2. Re: Richfaces - <rich:fileUpload>
            Felipe Regalgo Newbie

            HI!!!!

            YOur sugestion works very well, like a magic!!! :D

            my new web.xml is:

            
            <?xml version="1.0" encoding="UTF-8"?>
            <web-app id="WebApp_ID" 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">
             <display-name>RecordCompare</display-name>
             <!-- FACELETS -->
             <context-param>
             <param-name>facelets.REFRESH_PERIOD</param-name>
             <param-value>2</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>facelets.DEVELOPMENT</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>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>
             <!-- RICH FACES -->
             <context-param>
             <param-name>org.richfaces.SKIN</param-name>
             <param-value>compare</param-value>
             </context-param>
            
             <filter>
             <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>10485760</param-value>
             </init-param>
             </filter>
            
             <!-- TOMAHAWK -->
             <filter>
             <filter-name>MyFacesExtensionsFilter</filter-name>
             <filter-class>org.apache.myfaces.webapp.filter.ExtensionsFilter</filter-class>
             <init-param>
             <description>Set the size limit for uploaded files.
             Format: 10 - 10 bytes
             10k - 10 KB
             10m - 10 MB
             1g - 1 GB</description>
             <param-name>uploadMaxFileSize</param-name>
             <param-value>1g</param-value>
             </init-param>
             <init-param>
             <description>Set the threshold size - files
             below this limit are stored in memory, files above
             this limit are stored on disk.
            
             Format: 10 - 10 bytes
             10k - 10 KB
             10m - 10 MB
             1g - 1 GB</description>
             <param-name>uploadThresholdSize</param-name>
             <param-value>100m</param-value>
             </init-param>
             <!--
             <init-param> <param-name>uploadRepositoryPath</param-name>
             <param-value>/temp</param-value> <description>Set the path where the
             intermediary files will be stored. </description> </init-param>
             -->
             </filter>
            
            
             <!-- LOGIN -->
             <filter>
             <filter-name>LoginFilter</filter-name>
             <filter-class>code.filter.LoginFilter</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>
            
             <!--
             extension mapping for adding <script/>, <link/>, and other resource
             tags to JSF-pages
             -->
             <filter-mapping>
             <filter-name>MyFacesExtensionsFilter</filter-name>
             <servlet-name>Faces Servlet</servlet-name>
             <dispatcher>REQUEST</dispatcher>
             <dispatcher>FORWARD</dispatcher>
             <dispatcher>INCLUDE</dispatcher>
             <dispatcher>ERROR</dispatcher>
             </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>
            
            
            
             <filter-mapping>
             <filter-name>LoginFilter</filter-name>
             <url-pattern>/*</url-pattern>
             </filter-mapping>
             <listener>
             <listener-class>code.listener.ListenerDeInicializacao</listener-class>
             </listener>
             <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>*.jsf</url-pattern>
             </servlet-mapping>
             <session-config>
             <session-timeout>240</session-timeout>
             </session-config>
             <welcome-file-list>
             <welcome-file>index.jsp</welcome-file>
             </welcome-file-list>
             <login-config>
             <auth-method>BASIC</auth-method>
             </login-config>
            </web-app>
            
            
            


            thanks