I've written a moudle to retrieve property files without problem, hope it helps.
/*
* PropertyFile.java
* Retrieves parameter values from a property file.
* Properties must be in the CLASSPATH
* Created on February 16, 2001, 4:39 PM
*/
/**
*
* @author ernest
* @version
*/
import java.util.*;
import java.io.*;
import java.net.URL;
public class PropertyFile extends Object {
private String propsfilename;
public String getFileName() {
URL url = null;
try {
// read from top of any classpath entry
url = getClass().getResource("/" + propsfilename);
return url.getFile();
} catch (Exception e) {
System.out.println("Oops, can't find property file: " + propsfilename + " " + e);
}
return null;
}
public Hashtable getProperties() {
InputStream is = null;
Properties p = null;
try {
// read from top of any classpath entry
is = getClass().getResourceAsStream("/" + propsfilename);
p = new Properties();
p.load(is);
Hashtable table = new Hashtable();
for (Enumeration enum=p.keys(); enum.hasMoreElements(); ) {
String key = (String) enum.nextElement();
String value = p.getProperty(key);
table.put(key, value);
}
return table;
} catch (Exception e) {
System.out.println("Oops, can't parse property file: " + propsfilename + " " + e);
}
return null;
}
/** Creates new PropertyFile */
public PropertyFile(String prop) {
propsfilename = prop;
}
/**
* @param args the command line arguments
*/
public static void main (String args[]) {
PropertyFile pf = new PropertyFile("init.properties");
System.out.println(pf.getFileName());
System.out.println(pf.getProperties());
}
}
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, March 09, 2001 7:52 AM
To: JBoss-User
Subject: Re: [jBoss-User] Where are "properties" or "parameters" files
readfrom?
Sorry if this is a stupid question, but what do you mean by conf/<configname>?
I placed my file (mats.properties) in the following directories
\jboss_tomcat\jboss-2.0-final\conf\
\jboss_tomcat\jboss-2.0-final\conf\default
\jboss_tomcat\jboss-2.0-final\conf\tomcat
all of which ended up in the following message from jBoss:
[EmbeddedTomcat] Caught IOException: java.io.FileNotFoundException:
MATS.properties (The system cannot find the file spe
cified) trying to open file named MATS.properties
The properies file in question holds important information about where logging
information is stored on disk. I know this is a nit but it would help me out a
lot.
Any help would be greatly appreciated.
Thanks!
danch <[EMAIL PROTECTED]> on 03/08/2001 04:08:19 PM
Please respond to "JBoss-User" <[EMAIL PROTECTED]>
To: JBoss-User <[EMAIL PROTECTED]>
cc: (bcc: Kevin Monaghan/US/GM/GMC)
Subject: Re: [jBoss-User] Where are "properties" or "parameters" files
readfrom?
put it in (or under) conf/default (or conf/<configuration name>)
Do you know if the property file is loaded as '/filename' or
'org/something/filename'? In the first case, it needs to be in the root
of the classpath (which is right in conf/<configname>), in the other it
needs to be in a path under it that matches the specified path.
danch
[EMAIL PROTECTED] wrote:
>
> I am trying to use jLog 1.0 with jBoss 2.0 (final) to do all my logging and it
> needs to read a properties file. Where do I put the properties file so that it
> can be successfully read? BTW, I am using ANT to do builds.
>
> Thanks in advance,
>
> Kevin
>
> --
> --------------------------------------------------------------
> To subscribe: [EMAIL PROTECTED]
> To unsubscribe: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
--
--------------------------------------------------------------
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
