1 Reply Latest reply on Apr 14, 2008 10:02 AM by Bo Bruun

    Fileupload breaks JSF lifecycle

    Bo Bruun Newbie

      Hi, I'm using:
      Richfaces: 3.2.0 GA
      jBoss: 4.2.2 GA
      Seam: 2.0.1 GA

      The fileupload invoke my upload listener and i can access the file content.
      But when i press the submit button i get an exception. For me it looks like Richfaces have some problems (re-)rendering my fileupload tag in case of an error in my form.

      Exception:

      12:40:33,561 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=personal:securityNumberDecorate:securityNumber[severity=(ERROR 2), summary=(Wert erforderlich), detail=(Wert erforderlich)]
      12:40:33,576 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
      sourceId=personal:securityNumberDecorate:securityNumber[severity=(ERROR 2), summary=(Wert erforderlich), detail=(Wert erforderlich)]
      12:40:55,234 WARN [lifecycle] executePhase(APPLY_REQUEST_VALUES 2,com.sun.faces.context.FacesContextImpl@9e592c) threw exception
      javax.faces.FacesException
       at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:109)
       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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:80)
       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:147)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       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.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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       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:595)
      Caused by: java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:122)
       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.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:387)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:234)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:404)
       at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:101)
       ... 43 more
      12:40:55,234 ERROR [ExceptionFilter] handling uncaught exception
      javax.servlet.ServletException
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
       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.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:80)
       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:147)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       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.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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       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:595)
      Caused by: java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:122)
       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.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:387)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:234)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:404)
       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)
       ... 40 more
      12:40:55,234 ERROR [ExceptionFilter] exception root cause
      java.lang.NullPointerException
       at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRendererBase.java:122)
       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.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIForm.processDecodes(UIForm.java:203)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1001)
       at org.ajax4jsf.component.AjaxViewRoot$1.invokeContextCallback(AjaxViewRoot.java:387)
       at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:234)
       at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:404)
       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.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:83)
       at org.jboss.seam.debug.hot.HotDeployFilter.doFilter(HotDeployFilter.java:68)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.CharacterEncodingFilter.doFilter(CharacterEncodingFilter.java:42)
       at org.jboss.seam.servlet.SeamFilter$FilterChainImpl.doFilter(SeamFilter.java:69)
       at org.jboss.seam.web.MultipartFilter.doFilter(MultipartFilter.java:80)
       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:147)
       at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:276)
       at org.ajax4jsf.Filter.doFilter(Filter.java:175)
       at org.jboss.seam.web.Ajax4jsfFilter.doFilter(Ajax4jsfFilter.java:60)
       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.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.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:432)
       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:595)
      


      Part of my session bean
      @Stateful
      @Scope(ScopeType.SESSION)
      @Name("writtenReleaseAdmin")
      public class WrittenReleaseAdminAction implements WrittenReleaseAdmin {
      
      ...
      
      public String save() {
      
       ManufacturerUser mu = em.find(ManufacturerUser.class, user.getId());
       ManufacturerCom mc = mu.getManufacturerCom();
       Region r = em.find(Region.class, regionId);
       writtenRelease.setRegion(r);
       writtenRelease.setCreationDate(GregorianCalendar.getInstance().getTime());
      
       log.info("Save: " + new String(uploadFile.getAbsolutePath()));
      
       try {
       writtenRelease.setDocument(FileUtils.readFileToByteArray(uploadFile));
       } catch (Exception e) {
       facesMessages.add("Das hochladen der Freistellungsbescheinigung ist fehlgeschlagen. Bitte probieren Sie es nochmal.");
       return null;
       } finally {
       uploadFile.delete();
       }
      
       mc.getWrittenReleases().add(writtenRelease);
      
       em.persist(writtenRelease);
       em.merge(mc);
       return "home";
       }
      
       public void listener(UploadEvent event) throws IOException {
       UploadItem item = event.getUploadItem();
      
       if (item.isFile()) {
       uploadFile = item.getFile();
       } else {
       facesMessages.add("Das hochladen der Freistellungsbescheinigung ist fehlgeschlagen. Bitte probieren Sie es nochmal.");
       }
       log.info(new String(uploadFile.getAbsolutePath()));
       }
      


      Part of my Form
      <h:form id="personal" enctype="multipart/form-data">
       <rich:panel id="cPanel">
      
       <f:facet name="header">Freistellungsbescheinigung hinzufügen</f:facet>
      
       <rich:fileUpload fileUploadListener="#{writtenReleaseAdmin.listener}" />
      
      ...
      
      <h:commandButton id="save" value="Speichern" action="#{writtenReleaseAdmin.save}" styleClass="button" />
      
      ...