i think, if u put the file in WEB-INF, this shud work,
the only reason dat this code can fail is "improper path",
change the path as \\META-INF\\error.properties n check whether it works,
 
n let me know if works or not.
 
regds,
Zahir
 
----- Original Message -----
Sent: Tuesday, September 06, 2005 8:20 PM
Subject: Load file

Hi,
I want to read a file in EJB in bean method.
I have the file (error.prop) in the ejbmodule/META-INF folder.

When I right click on the ejb and click "Run on Server" to test it, I get
an Exception.Basically,the call fails in File.exists() method.
Below is the code.Can anyone please tell me the problem in the below code.

I know I can use ResourceBundle to load the file.But,want to know the
problem in the below code.The code looks ok to me.I tried putting the file
directly in ejbModule folder.No luck. I also tried setting strMessageFile
in the below code to "error.properties", "//error.properties" etc., It did
not work.

public class MessageBean implements javax.ejb.SessionBean {

public String getMessage(){
try {
 String strMessageFile = "\\error.properties";
java.io.File messageFile = new java.io.File(strMessageFile );
 if (messageFile .exists()){
  //Get the error message from file
   System.out.println("File exists");
   return "File Exists";
 }
 else{
    System.err.println( "Message file does not exist" );
    return "File Does not Exist";
}
}
catch(Exception ex)
{
 ex.printStackTrace();
}
}

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
=========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff EJB-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to