1 Reply Latest reply on Nov 30, 2006 11:43 PM by jaikiran pai

    Reading properties file

    sonali sharma Newbie


      I have an MBean, which along with other files is deployed as a .sar file in my application. I need to setup a properties file which will be read from this MBean file. I created a custom.properties file and placed it in META-INF.

      To read it, I tried the following commands:

      1) this.getClass().getClassLoader().getResource("custom.properties")
      2) ClassLoader.getSystemClassLoader().getResource("/META-INF/custom.properties")
      3) File props = new File("/META-INF/custom.properties");

      None of these seem to work, I get null in return.

      I do not have to place the file in META-INF, but I did this for my web application and read it in a servlet using -
      file = "/META-INF/custom.properties";

      and it worked.

      I think the problem is that my java class cannot read the file from within the .sar file.

      Does anyone have any suggestions? Thanks in advance.