3 Replies Latest reply on Feb 11, 2005 12:29 PM by Franco

    Unable to load .properties file

    James Adams Novice

      I have a JBoss application which is deployed in its own directory, for example JBOSS_HOME/server/myapp/deploy/myapp.sar. In this directory is a myapp.properties file. I have been unsuccessful at loading the Properties contained in this file, and I can't figure out why. First I tried a simple load using a FileInputStream, for example:

      String propertiesFileName = "myapp.properties";
      Properties myProperties;
      myProperties.load(new FileInputStream(propertiesFileName));

      I have also tried the following:

      String propertiesFileName = "myapp.properties";
      Properties myProperties;
      InputStream inputStream = ClassLoader.getSystemClassLoader().getResourceAsStream(propertiesFileName);
      myProperties.load(inputStream );

      The first example resulted in a FileNotFoundException, and the second results in a NullPointerException.

      In the run.sh I use to start JBoss I have made sure that the application's directory is in the $JBOSS_CLASSPATH, in order to make the myapp.properties file easy to locate.

      I am using JBoss 4.0.1.

      Thanks in advance for any suggestions as to how I might make this work.