Loading Configurable Parameters in a J2EE App


General J2EE: Loading Configurable Parameters in a J2EE App

  1. Loading Configurable Parameters in a J2EE App (6 messages)

    I have a Web Application calling 3rd party Web Services. This application needs a number of configurable parameters.

    For eg: Java.util.logging parameters, Web Services URLs and other parameters. Which is the best place to store them as configurable parameters?

    1. I can store them in my Web.xml and retrieve them in the Servlet, but I might have to redeploy my application everytime, one of the parameters changes.

    2. I can store them in a properties file, say, ABC.properties, using a static class or a Singleton to a access the properties. But is it OK to read configurable properties in this way from a J2EE application?

    3. Use a ResourceBundle?

    Which is the preferred way of loading configurable parameters in a J2EE Application?


    Threaded Messages (6)

  2. I am using JFig:
    "... JFig is a powerful yet easy-to-use configuration tool for Java applications. It allows developers to maintain more than one configuration for their applications, corresponding to different environments their application is intended to run in. JFig saves all these configurations in one common repository in a neat hierarchy, thus simplifying the location, management, and modification of different configurations. JFig also allows a developer to modify the configurations to make changes "on the fly" in the running application, thus saving time and efforts used in locating relevant configurations, making changes, stopping and restarting/redeploying the application to reflect these changes. ..."

    JFig can be downloaded for free with a LGPL license from Sourceforge ( http://jfig.sourceforge.net/ ).
  3. A Simpler Solution[ Go to top ]

    Thanks Gian,
      We are using Weblogic 8.1. Open Source Projects are a bit difficult to get approved by my managers over here.

    I am looking for a much simpler solution. I am not sure, if it would be OK for me to deploy my application in an exploded format and store my MyAppConfig.properties file in WEB-INF/Classes directory or APP-INF/lib directory.

  4. A Simpler Solution[ Go to top ]

    Why dont you have a table to store properties and have
    a read only bean to get those values.

  5. Simpler maintenance of the Config file[ Go to top ]


    Initial loading of the parameters from a database table might be alright.I can load them once and cache them in the memory, but how do I easily change/maintain the configurable parameters, going forward? Do I use SQL/Toad to access the table, or provide another tool to do that?

    Currently we have a 2-tier Java System which loads a properties file containing all the configuration parameters.
    It is easy to change the values in the properties file and all we need is restart the System during non-business hours. Our Operations team are very comfortable with this. I am also planning to do the same for the new J2EE project. But I wonder what the J2EE Puritans have to say about this. I intend to load the properties file from a static method(class) once from the Servlet!...Does this violate the J2EE Philosophy?

    Also, I intend to store the properties file containg all the necessary configuration parameters for my application in a directory that is in the classpath of the server and not in the ear file, as I am not keen on redeploying the application everytime, I change the values in the properties file.

    - Vishwa
  6. This might help..[ Go to top ]

    Check this page out. It might be helpful..

  7. I would not use Web.xml for that since none of your properties seem to relate to the web app configuration, but propety files should be good as well as ResourceBundle. I think in you case ResourceBundle should work out just fine and it provides an easy mechanism to get it using relative path.


    Artem D. Yegorov