tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Location of application-specific properties files
Date Tue, 06 Aug 2002 13:55:53 GMT

You must load your properties through some Classloader that is able to
locate your properties file.  For example you can use the class
PropertyResourceBundle for a real properties file or if you want to access
some own file format, just call the Thread.getCurrentThread
().getContextClassLoader().getResourceAsStream(...) function. Then the
WEB-INF/classes folder or some of your application specific .jar files in
WEB-INF/lib (if any) is the right place for it (and as far as i know, it is
the only standard way, which assures you to find a specific file on every
standard J2EE server).

Hope that helps,

Jens Stutte

                    "Robert Baker"                                                       
                    <robertbaker@ch        To:     "Tomcat Users List"                
          >             <>     
                    04/08/2002             Subject:     Location of application-specific properties
                    21.05                  files                                         
                    Please respond                                                       
                    to "Tomcat                                                           
                    Users List"                                                          

I am using Tomcat 4.0.3 under WinXP Pro, and I am trying to get my
application to "find" an application-specific properties file.  I am having
problems trying to determine which directory to put this file in.

Here is the Java code I am using for this class:

import java.util.Properties;

public class ForumProperties extends Properties {

   private static final String separator =
            System.getProperty("file.separator", ".");
   private static final String homeDirectory =
   private static final String DEFAULT_FILENAME = "";
   private static ForumProperties globalProps;

   private ForumProperties() {

   private ForumProperties(String fileName) throws Exception {
      load(new FileInputStream(fileName));

   public static ForumProperties getInstance() throws Exception {
      try {
         if (globalProps == null)
            globalProps = new ForumProperties(DEFAULT_FILENAME);
      } catch (Exception ex) {
         throw new Exception("Error loading properties file");
      return globalProps;


I have put the properties file in just about every directory I can think of
to try and find out where it's supposed to be, but I can't get it to work.
I can put the file into the "user.home" System property (which turns out to
be C:\Documents and Settings\Administrator) and have it pick it up, but I
would prefer to put the file into the directory tree of the application.

Is there an attribute or something in the server.xml or web.xml file I am
forgetting to set?

Can anyone help?


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message