1 Reply Latest reply on Jul 13, 2011 11:31 PM by Jack Robert

    Exception in rich:FileUpload

    Jack Robert Newbie

      Hi, When i click upload button  in rich:FileUpload , then the exception occur

       

       

      web.xml

       

      <filter>
               <display-name>RichFaces Filter</display-name> 
              <filter-name>richfaces</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>10000000</param-value>
              </init-param>
      
              <init-param>
                  <param-name>enable-cache</param-name>
                  <param-value>true</param-value>
              </init-param>
      
          </filter>
      

       

      And JSP page

       

      <h:form id="uploadForm" enctype="multipart/form-data">
      
        <h:panelGrid columns="2" columnClasses="top,top"                        
      
                <rich:fileUpload id="upload"
                             fileUploadListener="#{FileUploadDemo2.fileUploadListenerAction}"
                             acceptedTypes="jpg, gif, png, bmp, ico, jpeg"
                             maxFilesQuantity="1"                                         
                       <a4j:support event="onuploadcomplete" reRender="info,upload" />
                </rich:fileUpload>
      
                 <h:panelGroup id="info" layout="block">
                       <rich:panel bodyClass="info">
      
                              <a4j:mediaOutput element="img" mimeType="image/jpeg"
                                                 createContent="#{FileUploadDemo2.paint}"
                                                 style="width:100px; height:100px;" cacheable="false">
                                       <f:param value="#{FileUploadDemo2.timeStamp}" name="time" />
                                </a4j:mediaOutput>
      
                        </rich:panel>
      
                         <a4j:commandButton action="#{FileUploadDemo2.clearUploadData}"
                                                         reRender="info, upload"
                                                        value="Clear Uploaded Data"/>
                  </h:panelGroup>
           </h:panelGrid>
      
        </h:form>
      

       

      And Bean

       

       

      public class FileUploadDemo2
      {
          private byte[] imgaeData;    
      
          
       public void paint(OutputStream stream, Object object) throws IOException
        {
              try
              {
                  stream.write(imgaeData);
                  stream.close();
              }
              catch (Exception e)
              {
                  System.out.println("Paint Exception is : " + e);
              }
      
          }
      
          public void fileUploadListenerAction(UploadEvent event) throws Exception
          {
              try
              {
                  System.out.println("Listenenr called : ");
      
                  UploadItem item = event.getUploadItem();           
                  imgaeData = item.getData();                        
              }
              catch (Exception e)
              {
                  System.out.println("Listener Exception  : " + e);
              } 
          }
      
          public String clearUploadData()
          {
              imgaeData = null;       
              return null;
          }
      
          public long getTimeStamp()
          {
              return System.currentTimeMillis();
          }
      
      }
      

       

       

      The error is :

       

      javax.servlet.ServletException
          at javax.faces.webapp.FacesServlet.service(FacesServlet.java:277)
          at com.infomindz.platform.pl.CustomFacesServlet.service(CustomFacesServlet.java:97)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at com.infomindz.platform.pl.listeners.SSCMSSessionExpiryFilter.doFilter(SSCMSSessionExpiryFilter.java:97)
          at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
          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.java:235)
          at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
          at org.apache.myfaces.webapp.filter.ExtensionsFilter.doFilter(ExtensionsFilter.java:341)
          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:128)
          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:293)
          at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
          at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:574)
          at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1527)
          at java.lang.Thread.run(Thread.java:619)
      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:789)
          at javax.faces.component.UIInput.decode(UIInput.java:725)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1031)
          at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIForm.processDecodes(UIForm.java:209)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIInput.processDecodes(UIInput.java:639)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1026)
          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: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)
          ... 25 more
      

       

       

      Help me...

      Thanks in advance.

        • 1. Re: Exception in rich:FileUpload
          Jack Robert Newbie

          Now, i try to catch the exception,

           

          When i open the page print this error in my log

           


          Paint Exception is : java.lang.NullPointerException
          

           

          And, Aftte i click the upload button, i got the following exception

           

           

          Jul 14, 2011 11:29:47 AM com.sun.faces.lifecycle.Phase doPhase
          SEVERE: JSF1054: (Phase ID: APPLY_REQUEST_VALUES 2, View ID: /pages/samplePage.jsp) Exception thrown during phase execution: javax.faces.event.PhaseEvent[source=com.sun.faces.lifecycle.LifecycleImpl@19b88a6]
          Paint Exception is : java.lang.NullPointerException
          

           

          Help me.

          Thanks in advance...