3 Replies Latest reply on Feb 15, 2011 5:27 PM by Val Sw

    Null pointer exception in rich faces : FileUpload causing Transfer Error

    jayanth padmanabhan Newbie

      Hi,

           I am posting here as a last resort as i am aware this issue has been reported quite some times before but after reading all the comments and articles i am still not able to solve it. Please help.

       

      Issue Description:

      using richfaces:File Upload component, click Add.., select a file for Upload, and on clicking Upload, the progress bar appears only for a quick second and then it displays Transfer Error Occured. I have attached the jpg image of the error on the screen.

       

      Here are additional details. Please tell me if any more more information is needed.

       

      I am using Rich Faces 3.3.1 jars and tomahawk - 1.1.5 jar

       

      My web.xml is as follows:

      From issue RF-6947 i see it worked if we use our own filters first and then use Rich faces filters. I did thata and the order is as follows:

       

      <!-- some own security filters come first -->

       

      <!--  Rich Faces Params/Filters -->   

          <context-param>

              <param-name>org.ajax4jsf.SKIN</param-name>

              <param-value>DEFAULT</param-value>

          </context-param>

       

          <filter>

              <display-name>Ajax4jsf Filter</display-name>

              <filter-name>ajax4jsf</filter-name>

              <filter-class>org.ajax4jsf.Filter</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>20000000</param-value>

              </init-param>        

          </filter>

       

          <filter-mapping>

              <filter-name>ajax4jsf</filter-name>

              <servlet-name>Faces Servlet</servlet-name>

              <dispatcher>REQUEST</dispatcher>

              <dispatcher>FORWARD</dispatcher>

              <dispatcher>INCLUDE</dispatcher>

          </filter-mapping>

       

           <!-- TOMAHWAK FILTERS -->

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

               -->

              <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>maxFileSize</param-name>

                  <param-value>100m</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>100k</param-value>

              </init-param>

          </filter>   

          <filter-mapping>

              <filter-name>MyFacesExtensionsFilter</filter-name>

              <url-pattern>*.jsf</url-pattern>

          </filter-mapping>

          <filter-mapping>

              <filter-name>MyFacesExtensionsFilter</filter-name>

              <url-pattern>/faces/*</url-pattern>

          </filter-mapping>

       

          <!-- Faces 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-mapping>

              <servlet-name>Faces Servlet</servlet-name>

              <url-pattern>*.jsf</url-pattern>

          </servlet-mapping>

          <session-config>

              <session-timeout>30</session-timeout>

          </session-config>

       

      JSF code:

      <rich:fileUpload fileUploadListener="#{fileUploadBean.listener}"

                      maxFilesQuantity="#{fileUploadBean.uploadsAvailable}"

                      id="upload" immediateUpload="#{fileUploadBean.autoUpload}"

                      acceptedTypes="" allowFlash="#{fileUploadBean.useFlash}">

                      <a4j:support event="onuploadcomplete" reRender="info" />

                  </rich:fileUpload>

       

       

      My jboss logs:

      Caused by: java.lang.NullPointerException

              at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:140)

              at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)

              at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:764)

              at javax.faces.component.UIInput.decode(UIInput.java:719)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1006)

              at javax.faces.component.UIInput.processDecodes(UIInput.java:633)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)

              at javax.faces.component.UIForm.processDecodes(UIForm.java:203)

              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:101

       

              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)

              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

              ... 33 more

      19:32:17,474 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception

      java.lang.NullPointerException

              at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:140)

              at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:75)

              at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:764)

              at javax.faces.component.UIInput.decode(UIInput.java:719)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1006)

              at javax.faces.component.UIInput.processDecodes(UIInput.java:633)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)

              at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)

              at javax.faces.component.UIForm.processDecodes(UIForm.java:203)

              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:101

       

              at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)

              at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:117)

              at javax.faces.webapp.FacesServlet.service(FacesServlet.java:244)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.

      ava: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:365)

              at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:495)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.

      ava:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206

       

              at com.upnettec.gen2.security.ui.common.FeedbackFilter.doFilter(FeedbackFilter.java:50)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.

      ava:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206

       

              at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:147)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.

      ava:235)

              at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206

       

              at com.upnettec.gen2.security.ui.common.Gen2SecurityFilter.doFilter(Gen2SecurityFilter.java

      62)

              at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.

      ava: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.

      ava: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.j

      va: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.j

      va:583)

              at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:446)

              at java.lang.Thread.run(Thread.java:619)

       

       

      Thanks

      Jayanth

        • 1. Null pointer exception in rich faces : FileUpload causing Transfer Error
          Ilya Shaikovsky Master

          Your myFaces filter called first and that causes this issue. In order to fix - map myFaces filter using servlet-name instead of url-pattern. according to specification all the filters uses url-mapping's called first without difference in which order them placed in web.xml.

          • 2. Null pointer exception in rich faces : FileUpload causing Transfer Error
            jayanth padmanabhan Newbie

            Thanks Ilya. That did work out fine. Had to rearrange the filters.

            • 3. Null pointer exception in rich faces : FileUpload causing Transfer Error
              Val Sw Expert

              Hi Ilya,

               

              I am also getting same null pointer exception..

              java.lang.NullPointerException at com.....FileUploadBean.listener

               

              I tried various options but no success... please suggest what I am missing

               

              Here is web.xml...

               

              <?xml version="1.0" ?>

              <web-app 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"

                       version="2.5">

               

               

                  <!-- Ajax4jsf -->

                  <filter>

                                  <display-name>Ajax4jsf Filter</display-name>

                                  <filter-name>ajax4jsf</filter-name>

                                  <filter-class>org.ajax4jsf.Filter</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>2147483647</param-value>

                                  </init-param>

                        </filter>

                        <filter-mapping>

                                  <filter-name>ajax4jsf</filter-name>

                                  <servlet-name>Faces Servlet</servlet-name>

                                  <url-pattern>*.seam</url-pattern>

                                  <dispatcher>FORWARD</dispatcher>

                                  <dispatcher>REQUEST</dispatcher>

                                  <dispatcher>INCLUDE</dispatcher>

                                  <dispatcher>ERROR</dispatcher>

                        </filter-mapping>

                 

                  <context-param>

                      <param-name>org.richfaces.SKIN</param-name>

                      <param-value>blueSky</param-value>

                  </context-param>

               

                 <!-- Seam -->   

                 <listener>

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

                 </listener>

                 

                  <filter>

                      <filter-name>Seam Filter</filter-name>

                      <filter-class>org.jboss.seam.servlet.SeamFilter</filter-class>

                  </filter>

               

               

                  <filter-mapping>

                      <filter-name>Seam Filter</filter-name>

                      <url-pattern>/*</url-pattern>

                  </filter-mapping>

                     

                 <servlet>

                    <servlet-name>Seam Resource Servlet</servlet-name>

                    <servlet-class>org.jboss.seam.servlet.SeamResourceServlet</servlet-class>

                 </servlet>

                 

                 <servlet-mapping>

                    <servlet-name>Seam Resource Servlet</servlet-name>

                    <url-pattern>/seam/resource/*</url-pattern>

                 </servlet-mapping>

                

                 <!-- Facelets development mode (disable in production) -->  

                 <context-param>

                    <param-name>facelets.DEVELOPMENT</param-name>

                    <param-value>true</param-value>

                 </context-param>

                 

                 <!-- JSF -->  

                 <context-param>

                    <param-name>javax.faces.DEFAULT_SUFFIX</param-name>

                    <param-value>.xhtml</param-value>

                 </context-param>

               

               

                 <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>*.seam</url-pattern>

                 </servlet-mapping>

                               

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