title: System cannot find the file specify in jsf2.0
body: <p>I have using jsf2.0 in eclipse ide.I have a problem to store a image in local folder.The images are stored in local folder with 0 bytes.The images are read and write into 0 bytes.</p>
  
  <p>Backing Bean:</p>
  
  <p>public class uploadImageAction {</p>
  
  <pre><code>public void handleFileUpload(FileUploadEvent event) throws IOException {
  
  
      FacesContext context = FacesContext.getCurrentInstance();
      PhotoBean photoBean = (PhotoBean) context.getApplication().evaluateExpressionGet(context, "#{photoBean}", PhotoBean.class);
      PhotoBean photoBean2 = (PhotoBean) context.getApplication().evaluateExpressionGet(context, "#{photoBean2}", PhotoBean.class);
  
      ExternalContext extContext=FacesContext.getCurrentInstance().getExternalContext();
  
      File file = new  File(extContext.getRealPath(event.getFile().getFileName()));
  
  
        System.out.println("Hibernate save image into database");
          Session session = HibernateUtil1.getSessionFactory().openSession();
  
          session.beginTransaction();
  
          //save image into database
          //File file = new File("D:\\1.gif");
          //byte[] bFile = new byte[(int) file.length()];
          //System.out.println("DDDDDDDDDDDD"+bFile);
  
          byte[] bfile = new byte[(int)file.length()];
          System.out.println("DDDDDDDDDDDD"+bfile);
          try {
               FileInputStream fileInputStream = new FileInputStream(file);
               //convert file into array of bytes
               fileInputStream.read(bfile);
               fileInputStream.close();
              } catch (Exception e) {
                  System.out.println("Cannnoy");
               e.printStackTrace();
              }
  
          String urlImage = file.toString();
  
          String imageName = event.getFile().getFileName();
  
  
          photoBean.setPathName(file);
  
          //file = photoBean.getPathName();
  
          photoBean.setImageName(imageName);
  
          imageName = photoBean.getImageName();
  
          photoBean.setUrl(urlImage);
  
          urlImage = photoBean.getUrl();
  
  
      //  PhotoDaoService photoDaoService = new PhotoDaoService();
  
          System.out.println("+++++++++++++++++++++++++"+file);
  
  
   System.out.println("CHECK BYTES"+bfile);
       //   uploadImageBean upldImageBean = new uploadImageBean();
          //upldImageBean.setImageByte(bfile);
          photoBean.setByteImage(bfile);
          //avatar.setImage(bFile);
         // System.out.println("dfdffdf"+upldImageBean.setImageByte(bFile));
  
  
          session.save(photoBean);
  
  
          //Get image from database
           photoBean2 = (PhotoBean)session.get(PhotoBean.class, photoBean.getId());
          byte[] bImage = photoBean2.getByteImage();
          System.out.println("QQQQQQQQQQQQQQQ"+bImage);
          int i=0;
          try{
              FileOutputStream fos = new FileOutputStream("e:/out/out"+0+".jpg"); 
              fos.write(bImage);
              fos.close();
              FacesMessage msg = new FacesMessage("Succesful", event.getFile().getFileName()
                      + " is uploaded.");
  
                      FacesContext.getCurrentInstance().addMessage(null, msg);
          }catch(Exception e){
              e.printStackTrace();
              System.out.println("UPLOAD DISPLAY EXCEPTION");
          }
  
          session.getTransaction().commit();
      }
  
  }
  </code></pre>
  
  <p>The Error Occurs:</p>
  
  <pre><code>Hibernate save image into database
  bytes[B@12fb7ef
  java.io.FileNotFoundException: E:\Mecherie_project\.metadata\.plugins \org.eclipse.wst.server.core\tmp0\wtpwebapps\image_web\baby.jpg (The system cannot find  the file specified)
  
  at java.io.FileInputStream.open(Native Method)
  at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:120)
  at image.uploadImageAction.handleFileUpload(uploadImageAction.java:45)
  at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
  at   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
  at java.lang.reflect.Method.invoke(Method.java:597)
  at com.sun.el.parser.AstValue.invoke(AstValue.java:234)
  </code></pre>