0 Replies Latest reply on Oct 29, 2006 10:26 PM by scout1lacno

    Need help on exception:is java.io.FileNotFoundException:

    scout1lacno

      Hi all,

      Im new to EJB3 and JBOSS.

      I wanna materialize a BLOB data from MS SQL to Attachments folder, all data from this folder are generated from the Blob data I acquired. Can someone tell me where to put the folder in my EJB application. Is it in my WAR file? Im clueless.

      The error is below:

      D:\jboss-4.0.4.GA\server\default\.\tmp\deploy\tmp58870CustomerRelationsManagement.ear-contents\CustomerRelationsManagement-war-exp.war\Attachments\14344\MyIDPic.jpg (The system cannot find the path specified)


      My code is:


      byte[] fileBytes;
      
      
      while (rs.next()==true){
      
      
       String idmessage = rs.getString("IDMessage");
       String filenameX = rs.getString("strName");
       fileBytes = rs.getBytes("imgAttachment");
       File IDMesx = new File("/Attachments"+"/" + idmessage ); // Maybe my mistake is here
      
       Long myIDMessage = Long.parseLong(idmessage);
      
       ServletContext context = getServletConfig().getServletContext();
       String path = context.getRealPath( "/" + IDMesx);
       File myFile = new File(path);
       myFile.mkdir();
      
       OutputStream targetFile=
       new FileOutputStream(
       myFile + "/" + filenameX );
       targetFile.write(fileBytes);
       targetFile.close();
      
       String URL = context.getServletContextName() + "/Attachments/" + IDMes + "/" + filenameX ;
       out.write("Transfer ok " + URL);
      
      }


      Hope for a kind reply :)

      Thankz :)