2 Replies Latest reply on Aug 4, 2008 7:43 AM by Carles Pairot

    <rich:fileUpload> not working on RichFaces 3.2.1.GA

    Carles Pairot Newbie

      Hi all,

      I am having a weird problem with the <rich:fileUpload> component on RichFaces 3.2.1.GA, javax.faces 1.2_08 (Mojarra), Tomahawk 1.1.6 and JBoss 4.2.2.GA.

      When I upload a file, the following stack trace appears:

      11:29:19,779 FATAL [lifecycle] JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View
      ID: /altaAplicacio.jsp) Exception thrown during phase execution: javax.faces.eve
      nt.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1f6c65c]
      11:29:19,779 ERROR [BaseXMLFilter] Exception in the filter chain
      javax.servlet.ServletException
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
      Filter.java:100)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)

      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFil
      ter.java:362)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
      Filter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:179)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:524)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
      onnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
      ss(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
      6)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.NullPointerException
      at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRen
      dererBase.java:108)
      at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
      at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:784
      )
      at javax.faces.component.UIInput.decode(UIInput.java:725)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.
      java:1026)
      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(AjaxViewR
      oot.java:388)
      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:23
      5)
      at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:
      405)
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestV
      aluesPhase.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)
      ... 31 more
      11:29:19,779 ERROR [[Faces Servlet]] Servlet.service() para servlet Faces Servle
      t lanz¾ excepci¾n
      java.lang.NullPointerException
      at org.richfaces.renderkit.FileUploadRendererBase.doDecode(FileUploadRen
      dererBase.java:108)
      at org.ajax4jsf.renderkit.RendererBase.decode(RendererBase.java:76)
      at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:784
      )
      at javax.faces.component.UIInput.decode(UIInput.java:725)
      at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.
      java:1026)
      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(AjaxViewR
      oot.java:388)
      at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:23
      5)
      at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:
      405)
      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestV
      aluesPhase.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(Appl
      icationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
      Filter.java:100)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:154)

      at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:260)
      at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFil
      ter.java:362)
      at org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:493)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(Extensions
      Filter.java:147)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFi
      lter.java:96)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
      icationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
      ilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
      alve.java:230)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
      alve.java:175)
      at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(Securit
      yAssociationValve.java:179)
      at org.apache.catalina.authenticator.AuthenticatorBase.invoke(Authentica
      torBase.java:524)
      at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValv
      e.java:84)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
      ava:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
      ava:102)
      at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedC
      onnectionValve.java:157)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
      ve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav
      a:262)
      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
      :844)
      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
      ss(Http11Protocol.java:583)
      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:44
      6)
      at java.lang.Thread.run(Thread.java:619)

      My jsf code is:

      <rich:panel id="ejbBox">
      Provider URL:
      <h:inputText styleClass="required" value="#{applicationBean.ejbproviderurl}" size="40" id="ejbproviderurl" />
      EJB Lookup Name:
      <h:inputText styleClass="required" value="#{applicationBean.ejbjndilookup}" size="40" id="ejbjndilookup" />
      EJB Client Classes (*.jar):
      <rich:fileUpload fileUploadListener="#{applicationController.fileUploaded}" maxFilesQuantity="1" acceptedTypes="jar" id="uploadJAR" immediateUpload="true">
      </rich:fileUpload>
      Run-as:
      <h:inputText styleClass="required" value="#{applicationBean.ejbrunas}" size="40" id="ejbrunas" />
      </rich:panel>

      The bean code for the method is:

      public void fileUploaded (org.richfaces.event.UploadEvent ev) throws IOException {
      org.richfaces.model.UploadItem item = ev.getUploadItem();
      if (item==null) {
      System.out.println ("item==null");
      return;
      }

      System.out.println ("fileUploaded..." + item.getFileName());

      if (item.isTempFile()) {
      File file = item.getFile();
      System.out.println ("Absolute Path : '" + file.getAbsolutePath() + "'!");
      } else {
      ByteArrayOutputStream b = new ByteArrayOutputStream();
      if(item.getData() != null){
      b.write(item.getData());
      System.out.println (b.toString());
      }
      }
      }

      It seems the fileUploaded method isn't even being called. Any ideas will be appreciated.

      Thanks,

      --

      Carles.