1 Reply Latest reply on Jul 4, 2007 8:53 PM by jantzen

    Reading Runtime Property Files from EAR

    jantzen Newbie

      Hello,

      I'm trying to introduce runtime properties to my EAR-based application. Ideally I would read in a default properties file, and then an an overrides properties file into a java.util.Properties object to be queried by my application at runtime.

      Is there a standard way of doing this? The closet thing I've seen is the properties-service.xml mbean, but that looks like it is meant for VM specific properties, not application-specific properties.

      I've also tried loading the file as a module in my application.xml file but I get an "incomplete deployment" error on startup, even when specifying the alt-dd element.

      Any suggestions? Thanks,
      jantzen

        • 1. Re: Reading Runtime Property Files from EAR
          jantzen Newbie

          This works:

           Properties defaultProperties = new Properties();
           try {
           defaultProperties.load(getClass().getResourceAsStream("/default.runtime.properties"));
           } catch (IOException e) {
           log.error("Unable to open default properties file: " + e.getMessage());
           } catch (NullPointerException npe) {
           log.error("Unable to locate default properties file");
           }
           Properties runtimeProperties = new Properties(defaultProperties);
           try {
           runtimeProperties.load(getClass().getResourceAsStream("/runtime.properties"));
           } catch (IOException ioe) {
           log.error("Unable to open runtime properties file, using defaults: " + ioe.getMessage());
           } catch (NullPointerException npe) {
           log.error("Unable to locate runtime properties file, using defaults");
           }