5 Replies Latest reply on Jun 12, 2006 1:37 PM by peterj

    Configuration files outside of war file

    rknechtel

      I have a configuration directory in $JBOSS_HOME/configs I want to get at them from my application which resides inside a war file which is in an ear file. I am going nuts trying to figure out how to load the configuration (.properties files) fron my application.

      Anyone have any ideas/tips?

      Thanks much

        • 1. Re: Configuration files outside of war file
          visolvejboss

          Hello,

          Create a directory named libinside the war (WEB-INF/lib) and copy the configuration (.properties) files into lib directory. At runtime JBoss will automatically load these files.


          Regards,
          ViSolve JBoss Team.

          • 2. Re: Configuration files outside of war file
            peterj

            Try this:

            String jbossHome = System.getProperties("jboss.home.dir");
            Properties props = new Properties().load(new FileInputStream(jbossHome + "/" + propFileName ));


            where propFileName is the name of your properties file.

            • 3. Re: Configuration files outside of war file
              peterj

              Oops, change the file name in the last lin to read:

              jbossHome + "/configs" + propFileName

              • 4. Re: Configuration files outside of war file
                rknechtel


                Thanks for the information that works good!

                I myself am new to writing web apps for running on JBoss. I have been writing apps on the ATG framework for the last few years.

                What I am wondering is does JBoss support the concept of "components", basically you have a Java class and a .properties file for it.

                You would have a java class for example:
                com.my.classes.MyClass1

                and you have a properties file called MyClass1.properties that contains:
                $class=com.my.classes.MyClass1
                property1=test1
                property2=1,2,3,4,5

                In the properties file the $class is what links the properties file to the class and the entries "property1" and "property2" line up with "getters/setters" in MyClass1. So when you "load" the class the data is automatically loaded by the "setters" in the class.

                I hope this makes sense.

                Thanks

                • 5. Re: Configuration files outside of war file
                  peterj

                  I know that the Spring Framework enables you to do that, though there you have a single configuration file where you specify the property values of all of your beans.