0 Replies Latest reply on Aug 19, 2011 10:47 AM by yasser zairi

    <rich:fileUpload>   Listener Problem

    yasser zairi Newbie

      hi

      can anyone please tell me what's wrong with this:

        the listener methode in my bean:

       

      public void listener(UploadEvent event) throws Exception{

                  UploadItem item = event.getUploadItem();

                  fichier=new File("/home/zairi/Bureau/fichiertmp.xls");

                  fichier= item.getFile();

                  fetch(fichier);

              }

       

       

      the riche faces component :

       

      <h:form>

              <h:panelGrid columns="2" columnClasses="top,top">

                  <rich:fileUpload addControlLabel="Ajouter..."

                      stopEntryControlLabel="Arreter"

                      uploadControlLabel="Charger"

                      clearControlLabel="Supprimer"

                      clearAllControlLabel="Vider"

                       fileUploadListener="#{fileUploadBean.listener}"

                      maxFilesQuantity="#{fileUploadBean.uploadsAvailable}" id="upload"

                      immediateUpload="#{fileUploadBean.autoUpload}"

                      acceptedTypes="xls"

                      allowFlash="#{fileUploadBean.useFlash}">

                  </rich:fileUpload>

              </h:panelGrid>

             

             

          </h:form>

       

      my web.xml

       

      <listener>

              <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

          </listener>

          <listener>

              <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>

          </listener>

          <listener>

              <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

          </listener>

          <context-param>

              <param-name>contextConfigLocation</param-name>

              <param-value>classpath:application.context.xml</param-value>

          </context-param>

         

          <context-param>

              <param-name>org.eclipse.birt.configPath</param-name>

              <param-value>configuration/config.ini</param-value>

          </context-param>

         

          <servlet>

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

              <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

          </servlet>

         

          <servlet-mapping>

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

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

          </servlet-mapping>

         

          <filter>

              <filter-name>RichFaces Filter</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>102400</param-value>

              </init-param>

          </filter>

         

          <filter-mapping>

              <filter-name>RichFaces Filter</filter-name>

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

              <dispatcher>REQUEST</dispatcher>

              <dispatcher>FORWARD</dispatcher>

              <dispatcher>INCLUDE</dispatcher>

          </filter-mapping>

         

          <login-config>

              <auth-method>BASIC</auth-method>

          </login-config>

       

       

      and i get this error :

      ATTENTION: /GestionRef/upload.jsp @30,45 fileUploadListener="#{fileUploadBean.listener}": java.lang.NullPointerException

      javax.faces.el.EvaluationException: /GestionRef/upload.jsp @30,45 fileUploadListener="#{fileUploadBean.listener}": java.lang.NullPointerException

          at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:73)

          at org.richfaces.component.UIFileUpload.broadcast(UIFileUpload.java:190)

          at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)

          at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:302)

          at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)

          at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)

          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:206)

          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)

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

          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:127)

          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:298)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)

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

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

      Caused by: java.lang.NullPointerException

          at java.io.FileInputStream.<init>(FileInputStream.java:133)

          at jxl.Workbook.getWorkbook(Workbook.java:213)

          at jxl.Workbook.getWorkbook(Workbook.java:198)

          at cdvm.surv.web.FileUploadBean.fetch(FileUploadBean.java:45)

          at cdvm.surv.web.FileUploadBean.listener(FileUploadBean.java:39)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at java.lang.reflect.Method.invoke(Method.java:616)

          at org.apache.el.parser.AstValue.invoke(AstValue.java:191)

          at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

          at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)

          at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)

          ... 27 more

      19 août 2011 14:46:25 com.sun.faces.lifecycle.Phase doPhase

      GRAVE: JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View ID: /GestionRef/upload.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@1ddff76]

      19 août 2011 14:46:26 org.apache.catalina.core.StandardWrapperValve invoke

      GRAVE: "Servlet.service()" pour la servlet Faces Servlet a généré une exception

      java.lang.NullPointerException

          at java.io.FileInputStream.<init>(FileInputStream.java:133)

          at jxl.Workbook.getWorkbook(Workbook.java:213)

          at jxl.Workbook.getWorkbook(Workbook.java:198)

          at cdvm.surv.web.FileUploadBean.fetch(FileUploadBean.java:45)

          at cdvm.surv.web.FileUploadBean.listener(FileUploadBean.java:39)

          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)

          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)

          at java.lang.reflect.Method.invoke(Method.java:616)

          at org.apache.el.parser.AstValue.invoke(AstValue.java:191)

          at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)

          at com.sun.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:68)

          at com.sun.facelets.el.LegacyMethodBinding.invoke(LegacyMethodBinding.java:69)

          at org.richfaces.component.UIFileUpload.broadcast(UIFileUpload.java:190)

          at org.ajax4jsf.component.AjaxViewRoot.processEvents(AjaxViewRoot.java:329)

          at org.ajax4jsf.component.AjaxViewRoot.broadcastEventsForPhase(AjaxViewRoot.java:302)

          at org.ajax4jsf.component.AjaxViewRoot.processPhase(AjaxViewRoot.java:261)

          at org.ajax4jsf.component.AjaxViewRoot.processDecodes(AjaxViewRoot.java:417)

          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:206)

          at org.ajax4jsf.webapp.BaseFilter.handleRequest(BaseFilter.java:290)

          at org.ajax4jsf.webapp.BaseFilter.processUploadsAndHandleRequest(BaseFilter.java:367)

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

          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:127)

          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:298)

          at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)

          at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)

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

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