File load in EJB


EJB programming & troubleshooting: File load in EJB

  1. File load in EJB (1 messages)

    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 "", "//" etc., It did
    not work.

    public class MessageBean implements javax.ejb.SessionBean {

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

    Threaded Messages (1)

  2. File load in EJB[ Go to top ]


          According to the ejb specs an ejb should not try to use package to attempt to access a file .