title: I have faces the javax.faces.el.EvaluationException: java.lang.NullPointerException
body: <p>I am using jsf2.0 with tomcat7 in eclipse ide.I have just do a image cropping,when i crop the image and submit the form  there is a error in my code.i dont know where i am struct.</p>
  
  <p>My view page is:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://java.sun.com/jsf/facelets"
  xmlns:h="http://java.sun.com/jsf/html"
  xmlns:f="http://java.sun.com/jsf/core"
  xmlns:p="http://primefaces.prime.com.tr/ui"&gt;
  &lt;h:head&gt;
  &lt;script src="jquery-1.4.2.js"&gt;&lt;/script&gt;
  &lt;script src="jquery.Jcrop.js"&gt;&lt;/script&gt;
  &lt;script src="jquery.min.js"&gt;&lt;/script&gt;
  &lt;script src="jquery.Jcrop.min.js"&gt;&lt;/script&gt;
  
  &lt;/h:head&gt;
  &lt;h:body&gt;
  &lt;h:form&gt;  
  &lt;h:panelGrid columns="2"&gt;  
      &lt;p:imageCropper  value="#{imageCropperBean.croppedImage}"  
                  image="/detroit-nights.jpg"                     /&gt;  
       &lt;p:graphicImage id="localCroppedImage"  
                  value="#{imageCropperBean.newFileName}.jpg" /&gt;  
  
  &lt;/h:panelGrid&gt;  
  
  &lt;p:commandButton value="Crop"  
        update="localCroppedImage"  action="#{imageCrop.crop}"  
              /&gt;  
  
  
  &lt;/h:form&gt;  
  &lt;/h:body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The Backing Bean is:</p>
  
  <pre><code>package bean;
  
  
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.IOException;
  
  import javax.faces.bean.ManagedBean;
  import javax.faces.bean.RequestScoped;
  import javax.faces.context.FacesContext;
  import javax.imageio.stream.FileImageOutputStream;
  import javax.servlet.ServletContext;
  
  import org.primefaces.model.CroppedImage;
  
  @ManagedBean (name ="imageCrop")
  @RequestScoped
  public class ImageCropperBean {
  
      private CroppedImage croppedImage;
      private String newFileName;
  
  
      public String getNewFileName() {
          return newFileName;
      }
  
      public void setNewFileName(String newFileName) {
          this.newFileName = newFileName;
      }
  
      public CroppedImage getCroppedImage() {
              return croppedImage;
      }
  
      public void setCroppedImage(CroppedImage croppedImage) {
          System.out.println("cRRRRRRRRRRRRR"+croppedImage);
              this.croppedImage = croppedImage;
      }
  
      public String crop() {
          System.out.println("WELCOMEMMMMMMMMMMMMMM");
              ServletContext servletContext = (ServletContext)   FacesContext.getCurrentInstance().getExternalContext().getContext();
               newFileName = servletContext.getRealPath("") + File.separator +"croppedImage.jpg";
              System.out.println("FILE ANE"+newFileName);
  
              FileImageOutputStream imageOutput;
              try {   
                      //File file = new File(newFileName);
                      imageOutput = new FileImageOutputStream(new File(newFileName));
                      System.out.println("HHHHHHHHHH=="+imageOutput);
                      imageOutput.write(croppedImage.getBytes(), 0,  croppedImage.getBytes().length);
                      imageOutput.close();
              } catch (FileNotFoundException e) {
                  System.out.println("NOT FOUND EXCEPTION"+e);
                      e.printStackTrace();
              } catch (IOException e) {
                  System.out.println("IOEXCEPTION"+e);
                      e.printStackTrace();
              }
              //return newFileName;
              return null;
  
  
              }
  }
  </code></pre>
  
  <p>The web.xml is:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee /web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"&gt;
  &lt;context-param&gt;
  &lt;description&gt;Context param for JSTL 1.2 to work in Tomcat 6 sun RI
  &lt;/description&gt;
  &lt;param-name&gt;com.sun.faces.expressionFactory&lt;/param-name&gt;
  &lt;param-value&gt;com.sun.el.ExpressionFactoryImpl&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
  &lt;description&gt;Parameter required by Mojarra 2.0&lt;/description&gt;
  &lt;param-name&gt;com.sun.faces.allowTextChildren&lt;/param-name&gt;
  &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;javax.faces.VALIDATE_EMPTY_FIELDS&lt;/param-name&gt;
  &lt;param-value&gt;true&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;Resource Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;
      org.primefaces.resource.ResourceServlet
  &lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Resource Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/primefaces_resource/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;javax.faces.PROJECT_STAGE&lt;/param-name&gt;
  &lt;param-value&gt;Development&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;javax.faces.STATE_SAVING_METHOD&lt;/param-name&gt;
  &lt;param-value&gt;server&lt;/param-value&gt;
  &lt;/context-param&gt;
  &lt;filter&gt;
  &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
  &lt;filter-class&gt;org.primefaces.webapp.filter.FileUploadFilter&lt;/filter-class&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;thresholdSize&lt;/param-name&gt;
    &lt;param-value&gt;2097152&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;init-param&gt;
    &lt;param-name&gt;uploadDirectory&lt;/param-name&gt;
    &lt;param-value&gt;/temp&lt;/param-value&gt;
  &lt;/init-param&gt;
  &lt;/filter&gt;
  &lt;filter-mapping&gt;
  &lt;filter-name&gt;PrimeFaces FileUpload Filter&lt;/filter-name&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;/filter-mapping&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;servlet-class&gt;javax.faces.webapp.FacesServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/faces/*&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.xhtml&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;Faces Servlet&lt;/servlet-name&gt;
  &lt;url-pattern&gt;*.jsf&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;session-config&gt;
  &lt;session-timeout&gt;30&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  &lt;welcome-file-list&gt;
  &lt;welcome-file&gt;image.xhtml&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;/web-app&gt;
  </code></pre>