1 Reply Latest reply on Sep 7, 2008 2:54 PM by Roland Schär

    rich:fileUpload is not working

    Roland Schär Newbie

      I try to get a rich:fileUpload working in my page but i only get weird exceptions when uploading files. The createTempFiles is set to true and i use JBoss 4.2.2, JSF-RI, Facelets 1.1.14 and Richfaces 3.2.2.CR2.

      When i try to update a file the following error occurs in the log:

      2008-09-07 19:44:53,905 ERROR [org.apache.catalina.core.ContainerBase.[jboss.web].[localhost].[/sndbx].[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:114)
       at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
       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.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.java:290)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
       at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:177)
       at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:267)
       at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:376)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:507)
       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:147)
       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(Thread.java:619)
      



      Below you will find my code
      JSF...
      <h:form id="uploadForm" enctype="multipart/form-data">
       <fieldset>
       <legend>Upload</legend>
      
       <rich:messages showDetail="false"
       errorClass="msgError" warnClass="msgWarn" infoClass="msgInfo" />
      
       <label for="upload">Musikdatei(en): *</label>
       <rich:fileUpload id="upload"
       uploadData="#{playlistAction.files}"
       fileUploadListener="#{playlistAction.listener}"
       maxFilesQuantity="#{playlistAction.uploadsAvailable}"
       listHeight="100px" listWidth="100%"
       uploadControlLabel="Hinzufuegen">
       </rich:fileUpload>
      ...
      </h:form>
      


      Bean...
       public synchronized void listener(UploadEvent event) throws Exception {
      
       FacesContext ctx = FacesContext.getCurrentInstance();
       UploadItem item = event.getUploadItem();
      
       //store track
      
       //save file
      
       }
      


      faces-config.xml ...
      <managed-bean>
       <managed-bean-name>playlistAction</managed-bean-name>
       <managed-bean-class>
       ch.rolandschaer.sndbx.webgui.action.PlaylistAction
       </managed-bean-class>
       <managed-bean-scope>request</managed-bean-scope>
       <managed-property>
       <property-name>visit</property-name>
       <value>#{visit}</value>
       </managed-property>
      </managed-bean>