Re: Loading Properties Files

2002-12-04 Thread Will Hartung
 From: [EMAIL PROTECTED]
 Subject: Loading Properties Files


 My problem is that the class cannot location my properties file. I am
 unable to
 use other suggested methods that I have noticed on this list since those
 problems
 involved Properties File within Servlets.

 After some testing, I determined for some reason the default directory it
 is looking
 for my properties file is the Windows System Directory (Determined this by
 opening
 a file in the default directory, outputing something in it and searching
 for the file).

 Anyone have any ideas on how to solve this problem? I do not want to hard
 code the
 exact location due to obvious reasons

The problem is that you appear to be loading a file with an absolute path,
versus the common form of load a properties file via the ClassLoader.

Fumble about with the ClassLoader.getResourceAsStream to have it hunt down
your properties file, and then feed that stream to your Properties.

public static yourMethod()
{
ClassLoader cl = YourClass.class.getClassLoader();
Properties prop = new Properties();
prop.load(cl.getResourceAsStream(yours.properties));
}

Then, just drop your properties at the right place in your WARs classes
area.

Regards,

Will Hartung
([EMAIL PROTECTED])




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading Properties Files

2002-12-04 Thread Roberto Bouza

 Thats right.

 If you don't have a .war file, you can use the classes dir inside your WEB-INF
dir, and create a new directory like conf, the put inside all the properties
files. In that way the ClassLoader looks for  the files in there when you use
something like this:

try {
Properties props = new Properties();
InputStream in = getClass().getResourceAsStream(/conf/db.properties);
props.load(in);
..
  
 propertie1 = props.getProperty(propertie1);

 C'ya

Quoting Will Hartung [EMAIL PROTECTED]:

  From: [EMAIL PROTECTED]
  Subject: Loading Properties Files
 
 
  My problem is that the class cannot location my properties file. I am
  unable to
  use other suggested methods that I have noticed on this list since those
  problems
  involved Properties File within Servlets.
 
  After some testing, I determined for some reason the default directory it
  is looking
  for my properties file is the Windows System Directory (Determined this
 by
  opening
  a file in the default directory, outputing something in it and searching
  for the file).
 
  Anyone have any ideas on how to solve this problem? I do not want to hard
  code the
  exact location due to obvious reasons
 
 The problem is that you appear to be loading a file with an absolute path,
 versus the common form of load a properties file via the ClassLoader.
 
 Fumble about with the ClassLoader.getResourceAsStream to have it hunt down
 your properties file, and then feed that stream to your Properties.
 
 public static yourMethod()
 {
 ClassLoader cl = YourClass.class.getClassLoader();
 Properties prop = new Properties();
 prop.load(cl.getResourceAsStream(yours.properties));
 }
 
 Then, just drop your properties at the right place in your WARs classes
 area.
 
 Regards,
 
 Will Hartung
 ([EMAIL PROTECTED])
 
 
 
 
 --
 To unsubscribe, e-mail:  
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 


-- 
= Roberto Bouza Fraga   =
===
  Research  Development Engineer
   Ella Cisneros Fontanals Holdings
 Ph: (305)-860-0116 / Fax:(305)-860-9401
===
   e-Mail:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Loading Properties Files

2002-12-04 Thread Jay Wright

And if you have a .war file?  Then where would you put your properties
files?

 -Original Message-
 From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 2:49 PM
 To: Tomcat Users List
 Subject: Re: Loading Properties Files
 
 
 
  Thats right.
 
  If you don't have a .war file, you can use the classes dir 
 inside your WEB-INF
 dir, and create a new directory like conf, the put inside 
 all the properties
 files. In that way the ClassLoader looks for  the files in 
 there when you use
 something like this:
 
   try {
   Properties props = new Properties();
   InputStream in = 
 getClass().getResourceAsStream(/conf/db.properties);
   props.load(in);
 ..
   
  propertie1 = props.getProperty(propertie1);
 
  C'ya
 
 Quoting Will Hartung [EMAIL PROTECTED]:
 
   From: [EMAIL PROTECTED]
   Subject: Loading Properties Files
  
  
   My problem is that the class cannot location my 
 properties file. I am
   unable to
   use other suggested methods that I have noticed on this 
 list since those
   problems
   involved Properties File within Servlets.
  
   After some testing, I determined for some reason the 
 default directory it
   is looking
   for my properties file is the Windows System Directory 
 (Determined this
  by
   opening
   a file in the default directory, outputing something in 
 it and searching
   for the file).
  
   Anyone have any ideas on how to solve this problem? I do 
 not want to hard
   code the
   exact location due to obvious reasons
  
  The problem is that you appear to be loading a file with an 
 absolute path,
  versus the common form of load a properties file via the 
 ClassLoader.
  
  Fumble about with the ClassLoader.getResourceAsStream to 
 have it hunt down
  your properties file, and then feed that stream to your Properties.
  
  public static yourMethod()
  {
  ClassLoader cl = YourClass.class.getClassLoader();
  Properties prop = new Properties();
  prop.load(cl.getResourceAsStream(yours.properties));
  }
  
  Then, just drop your properties at the right place in your 
 WARs classes
  area.
  
  Regards,
  
  Will Hartung
  ([EMAIL PROTECTED])
  
  
  
  
  --
  To unsubscribe, e-mail:  
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
  mailto:[EMAIL PROTECTED]
  
  
 
 
 -- 
 = Roberto Bouza Fraga   =
 ===
   Research  Development Engineer
Ella Cisneros Fontanals Holdings
  Ph: (305)-860-0116 / Fax:(305)-860-9401
 ===
e-Mail:[EMAIL PROTECTED]
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Loading Properties Files

2002-12-04 Thread micael
Depends upon what you want to do with the properties files and how you 
access them.  Some ways of accessing them require that the name to access 
be relative to the classpath, others don't.  You are better off to learn 
about properties files in this instance.  There is nothing peculiar to the 
web-structure that I know of that is important about locating properties 
files.

At 03:14 PM 12/4/2002 -0800, you wrote:

And if you have a .war file?  Then where would you put your properties
files?

 -Original Message-
 From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 2:49 PM
 To: Tomcat Users List
 Subject: Re: Loading Properties Files



  Thats right.

  If you don't have a .war file, you can use the classes dir
 inside your WEB-INF
 dir, and create a new directory like conf, the put inside
 all the properties
 files. In that way the ClassLoader looks for  the files in
 there when you use
 something like this:

   try {
   Properties props = new Properties();
   InputStream in =
 getClass().getResourceAsStream(/conf/db.properties);
   props.load(in);
 ..

  propertie1 = props.getProperty(propertie1);

  C'ya

 Quoting Will Hartung [EMAIL PROTECTED]:

   From: [EMAIL PROTECTED]
   Subject: Loading Properties Files
 
 
   My problem is that the class cannot location my
 properties file. I am
   unable to
   use other suggested methods that I have noticed on this
 list since those
   problems
   involved Properties File within Servlets.
  
   After some testing, I determined for some reason the
 default directory it
   is looking
   for my properties file is the Windows System Directory
 (Determined this
  by
   opening
   a file in the default directory, outputing something in
 it and searching
   for the file).
  
   Anyone have any ideas on how to solve this problem? I do
 not want to hard
   code the
   exact location due to obvious reasons
 
  The problem is that you appear to be loading a file with an
 absolute path,
  versus the common form of load a properties file via the
 ClassLoader.
 
  Fumble about with the ClassLoader.getResourceAsStream to
 have it hunt down
  your properties file, and then feed that stream to your Properties.
 
  public static yourMethod()
  {
  ClassLoader cl = YourClass.class.getClassLoader();
  Properties prop = new Properties();
  prop.load(cl.getResourceAsStream(yours.properties));
  }
 
  Then, just drop your properties at the right place in your
 WARs classes
  area.
 
  Regards,
 
  Will Hartung
  ([EMAIL PROTECTED])
 
 
 
 
  --
  To unsubscribe, e-mail:
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
  mailto:[EMAIL PROTECTED]
 
 


 --
 = Roberto Bouza Fraga   =
 ===
   Research  Development Engineer
Ella Cisneros Fontanals Holdings
  Ph: (305)-860-0116 / Fax:(305)-860-9401
 ===
e-Mail:[EMAIL PROTECTED]

 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]


Micael

---

This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank you 



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



RE: Loading Properties Files

2002-12-04 Thread Jay Wright

If I understand you correctly, the properties file CANNOT be in the war
file, it needs to be external.  Right.

 -Original Message-
 From: micael [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 3:25 PM
 To: Tomcat Users List
 Subject: RE: Loading Properties Files
 
 
 Depends upon what you want to do with the properties files 
 and how you 
 access them.  Some ways of accessing them require that the 
 name to access 
 be relative to the classpath, others don't.  You are better 
 off to learn 
 about properties files in this instance.  There is nothing 
 peculiar to the 
 web-structure that I know of that is important about locating 
 properties 
 files.
 
 At 03:14 PM 12/4/2002 -0800, you wrote:
 
 And if you have a .war file?  Then where would you put your 
 properties
 files?
 
   -Original Message-
   From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, December 04, 2002 2:49 PM
   To: Tomcat Users List
   Subject: Re: Loading Properties Files
  
  
  
Thats right.
  
If you don't have a .war file, you can use the classes dir
   inside your WEB-INF
   dir, and create a new directory like conf, the put inside
   all the properties
   files. In that way the ClassLoader looks for  the files in
   there when you use
   something like this:
  
 try {
 Properties props = new Properties();
 InputStream in =
   getClass().getResourceAsStream(/conf/db.properties);
 props.load(in);
   ..
  
propertie1 = props.getProperty(propertie1);
  
C'ya
  
   Quoting Will Hartung [EMAIL PROTECTED]:
  
 From: [EMAIL PROTECTED]
 Subject: Loading Properties Files
   
   
 My problem is that the class cannot location my
   properties file. I am
 unable to
 use other suggested methods that I have noticed on this
   list since those
 problems
 involved Properties File within Servlets.

 After some testing, I determined for some reason the
   default directory it
 is looking
 for my properties file is the Windows System Directory
   (Determined this
by
 opening
 a file in the default directory, outputing something in
   it and searching
 for the file).

 Anyone have any ideas on how to solve this problem? I do
   not want to hard
 code the
 exact location due to obvious reasons
   
The problem is that you appear to be loading a file with an
   absolute path,
versus the common form of load a properties file via the
   ClassLoader.
   
Fumble about with the ClassLoader.getResourceAsStream to
   have it hunt down
your properties file, and then feed that stream to your 
 Properties.
   
public static yourMethod()
{
ClassLoader cl = YourClass.class.getClassLoader();
Properties prop = new Properties();
prop.load(cl.getResourceAsStream(yours.properties));
}
   
Then, just drop your properties at the right place in your
   WARs classes
area.
   
Regards,
   
Will Hartung
([EMAIL PROTECTED])
   
   
   
   
--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]
   
   
  
  
   --
   = Roberto Bouza Fraga   =
   ===
 Research  Development Engineer
  Ella Cisneros Fontanals Holdings
Ph: (305)-860-0116 / Fax:(305)-860-9401
   ===
  e-Mail:[EMAIL PROTECTED]
  
   --
   To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 --
 To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

Micael

---

This electronic mail  transmission and any accompanying documents contain 
information belonging to the sender which may be confidential and legally 
privileged.  This information is intended only for the use of the 
individual or entity to whom this electronic mail transmission was sent as 
indicated above. If you are not the intended recipient, any disclosure, 
copying, distribution, or action taken in reliance on the contents of the 
information contained in this transmission is strictly prohibited.  If you 
have received this transmission in error, please delete the message.  Thank
you 



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading Properties Files

2002-12-04 Thread Will Hartung
If you're using the ClassLoader to locate your properties files, then the
properties files need to be within your classpath. For WARs, the only places
that you really have much control over is the 'classes' directory.

The other issue is that your can not assume that you will be able to write
to you properties files.

Will

- Original Message -
From: Jay Wright [EMAIL PROTECTED]
To: 'Tomcat Users List' [EMAIL PROTECTED]
Sent: Wednesday, December 04, 2002 3:37 PM
Subject: RE: Loading Properties Files



 If I understand you correctly, the properties file CANNOT be in the war
 file, it needs to be external.  Right.

  -Original Message-
  From: micael [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, December 04, 2002 3:25 PM
  To: Tomcat Users List
  Subject: RE: Loading Properties Files
 
 
  Depends upon what you want to do with the properties files
  and how you
  access them.  Some ways of accessing them require that the
  name to access
  be relative to the classpath, others don't.  You are better
  off to learn
  about properties files in this instance.  There is nothing
  peculiar to the
  web-structure that I know of that is important about locating
  properties
  files.
 
  At 03:14 PM 12/4/2002 -0800, you wrote:
 
  And if you have a .war file?  Then where would you put your
  properties
  files?
  
-Original Message-
From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, December 04, 2002 2:49 PM
To: Tomcat Users List
Subject: Re: Loading Properties Files
   
   
   
 Thats right.
   
 If you don't have a .war file, you can use the classes dir
inside your WEB-INF
dir, and create a new directory like conf, the put inside
all the properties
files. In that way the ClassLoader looks for  the files in
there when you use
something like this:
   
  try {
  Properties props = new Properties();
  InputStream in =
getClass().getResourceAsStream(/conf/db.properties);
  props.load(in);
..
   
 propertie1 = props.getProperty(propertie1);
   
 C'ya
   
Quoting Will Hartung [EMAIL PROTECTED]:
   
  From: [EMAIL PROTECTED]
  Subject: Loading Properties Files


  My problem is that the class cannot location my
properties file. I am
  unable to
  use other suggested methods that I have noticed on this
list since those
  problems
  involved Properties File within Servlets.
 
  After some testing, I determined for some reason the
default directory it
  is looking
  for my properties file is the Windows System Directory
(Determined this
 by
  opening
  a file in the default directory, outputing something in
it and searching
  for the file).
 
  Anyone have any ideas on how to solve this problem? I do
not want to hard
  code the
  exact location due to obvious reasons

 The problem is that you appear to be loading a file with an
absolute path,
 versus the common form of load a properties file via the
ClassLoader.

 Fumble about with the ClassLoader.getResourceAsStream to
have it hunt down
 your properties file, and then feed that stream to your
  Properties.

 public static yourMethod()
 {
 ClassLoader cl = YourClass.class.getClassLoader();
 Properties prop = new Properties();
 prop.load(cl.getResourceAsStream(yours.properties));
 }

 Then, just drop your properties at the right place in your
WARs classes
 area.

 Regards,

 Will Hartung
 ([EMAIL PROTECTED])




 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]


   
   
--
= Roberto Bouza Fraga   =
===
  Research  Development Engineer
   Ella Cisneros Fontanals Holdings
 Ph: (305)-860-0116 / Fax:(305)-860-9401
===
   e-Mail:[EMAIL PROTECTED]
   
--
To unsubscribe, e-mail:
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
  mailto:[EMAIL PROTECTED]
  
  --
  To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]

 Micael

 ---

 This electronic mail  transmission and any accompanying documents contain
 information belonging to the sender which may be confidential and legally
 privileged.  This information is intended only for the use of the
 individual or entity to whom this electronic mail transmission was sent as
 indicated above. If you are not the intended recipient, any disclosure,
 copying, distribution, or action taken in reliance on the contents of the
 information contained in this transmission is strictly

RE: Loading Properties Files

2002-12-04 Thread Jacob Kjome

No, that's not true at all.

The examples already given will find properties files for you just fine 
whether the file is in a directory structure or inside an archive.  How do 
you think Java loads classes?  It works out of archives, no?

here are some various was to access a properties file ( or any resource, 
for that matter) in whether the app is deployed as a directory or as a .war 
file (even inside a .jar file in WEB-INF/lib)

This will load a file in WEB-INF/classes/conf or any jar file in the 
classpath with a package of conf...
getClass().getResourceAsStream(/conf/db.properties);

This will load a file relative to the current class.  For instance, if the 
class is org.mypackage.MyClass, then the file would be loaded at 
org.mypackage.conf.dbproperties.  Note that this is because we didn't 
prepend / to the path.  When that is done, the file is loaded from the 
root of the current classloader where this loads it relative to the current 
class...
getClass().getResourceAsStream(conf/db.properties);

this will find db.properties anywhere in the current classloader as long as 
it exists in a conf package...
getClass().getClassLoader().getResourceAsStream(conf/db.properties);


This will find the file in a conf directory inside the webapp (starting 
from the root).  This starts looking in the same directory as contains 
WEB-INF.  When I say directory, I don't mean filesystem.  This could be 
in a .war file as well as in an actual directory on the filesystem...
getServletContext().getResourceAsStream(/conf/db.properties);

of course you would probably not want just anyone seeing your db.properties 
file, so you'd probably want to put in inside WEB-INF of your webapp, so
getServletContext().getResourceAsStream(/WEB-INF/conf/db.properties);

If your db.properties exists in another classloader which your app has 
access to, you can reach it by using:
Thread.currentThread().getContextClassLoader().getResourceAsStream(conf/db.properties);

That will act similar to getClass().getClassLoader(), but it can see across 
all available classloaders where the latter can only see within the 
classloader that loaded the current class.

So, as you can see, you have quite a number of options.  There you go.

Jake

At 03:37 PM 12/4/2002 -0800, you wrote:

If I understand you correctly, the properties file CANNOT be in the war
file, it needs to be external.  Right.

 -Original Message-
 From: micael [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 3:25 PM
 To: Tomcat Users List
 Subject: RE: Loading Properties Files


 Depends upon what you want to do with the properties files
 and how you
 access them.  Some ways of accessing them require that the
 name to access
 be relative to the classpath, others don't.  You are better
 off to learn
 about properties files in this instance.  There is nothing
 peculiar to the
 web-structure that I know of that is important about locating
 properties
 files.

 At 03:14 PM 12/4/2002 -0800, you wrote:

 And if you have a .war file?  Then where would you put your
 properties
 files?
 
   -Original Message-
   From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, December 04, 2002 2:49 PM
   To: Tomcat Users List
   Subject: Re: Loading Properties Files
  
  
  
Thats right.
  
If you don't have a .war file, you can use the classes dir
   inside your WEB-INF
   dir, and create a new directory like conf, the put inside
   all the properties
   files. In that way the ClassLoader looks for  the files in
   there when you use
   something like this:
  
 try {
 Properties props = new Properties();
 InputStream in =
   getClass().getResourceAsStream(/conf/db.properties);
 props.load(in);
   ..
  
propertie1 = props.getProperty(propertie1);
  
C'ya
  
   Quoting Will Hartung [EMAIL PROTECTED]:
  
 From: [EMAIL PROTECTED]
 Subject: Loading Properties Files
   
   
 My problem is that the class cannot location my
   properties file. I am
 unable to
 use other suggested methods that I have noticed on this
   list since those
 problems
 involved Properties File within Servlets.

 After some testing, I determined for some reason the
   default directory it
 is looking
 for my properties file is the Windows System Directory
   (Determined this
by
 opening
 a file in the default directory, outputing something in
   it and searching
 for the file).

 Anyone have any ideas on how to solve this problem? I do
   not want to hard
 code the
 exact location due to obvious reasons
   
The problem is that you appear to be loading a file with an
   absolute path,
versus the common form of load a properties file via the
   ClassLoader.
   
Fumble about with the ClassLoader.getResourceAsStream to
   have it hunt down
your properties file, and then feed that stream to your
 Properties

RE: Loading Properties Files

2002-12-04 Thread micael
A .war file is just a wrapper for a web application.  I think he does not 
know what one is.  It is like a .zip or a .jar file.  Do you know that?

At 06:56 PM 12/4/2002 -0600, you wrote:

No, that's not true at all.

The examples already given will find properties files for you just fine 
whether the file is in a directory structure or inside an archive.  How do 
you think Java loads classes?  It works out of archives, no?

here are some various was to access a properties file ( or any resource, 
for that matter) in whether the app is deployed as a directory or as a 
.war file (even inside a .jar file in WEB-INF/lib)

This will load a file in WEB-INF/classes/conf or any jar file in the 
classpath with a package of conf...
getClass().getResourceAsStream(/conf/db.properties);

This will load a file relative to the current class.  For instance, if the 
class is org.mypackage.MyClass, then the file would be loaded at 
org.mypackage.conf.dbproperties.  Note that this is because we didn't 
prepend / to the path.  When that is done, the file is loaded from the 
root of the current classloader where this loads it relative to the 
current class...
getClass().getResourceAsStream(conf/db.properties);

this will find db.properties anywhere in the current classloader as long 
as it exists in a conf package...
getClass().getClassLoader().getResourceAsStream(conf/db.properties);


This will find the file in a conf directory inside the webapp (starting 
from the root).  This starts looking in the same directory as contains 
WEB-INF.  When I say directory, I don't mean filesystem.  This could 
be in a .war file as well as in an actual directory on the filesystem...
getServletContext().getResourceAsStream(/conf/db.properties);

of course you would probably not want just anyone seeing your 
db.properties file, so you'd probably want to put in inside WEB-INF of 
your webapp, so
getServletContext().getResourceAsStream(/WEB-INF/conf/db.properties);

If your db.properties exists in another classloader which your app has 
access to, you can reach it by using:
Thread.currentThread().getContextClassLoader().getResourceAsStream(conf/db.properties);

That will act similar to getClass().getClassLoader(), but it can see 
across all available classloaders where the latter can only see within the 
classloader that loaded the current class.

So, as you can see, you have quite a number of options.  There you go.

Jake

At 03:37 PM 12/4/2002 -0800, you wrote:

If I understand you correctly, the properties file CANNOT be in the war
file, it needs to be external.  Right.

 -Original Message-
 From: micael [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 3:25 PM
 To: Tomcat Users List
 Subject: RE: Loading Properties Files


 Depends upon what you want to do with the properties files
 and how you
 access them.  Some ways of accessing them require that the
 name to access
 be relative to the classpath, others don't.  You are better
 off to learn
 about properties files in this instance.  There is nothing
 peculiar to the
 web-structure that I know of that is important about locating
 properties
 files.

 At 03:14 PM 12/4/2002 -0800, you wrote:

 And if you have a .war file?  Then where would you put your
 properties
 files?
 
   -Original Message-
   From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, December 04, 2002 2:49 PM
   To: Tomcat Users List
   Subject: Re: Loading Properties Files
  
  
  
Thats right.
  
If you don't have a .war file, you can use the classes dir
   inside your WEB-INF
   dir, and create a new directory like conf, the put inside
   all the properties
   files. In that way the ClassLoader looks for  the files in
   there when you use
   something like this:
  
 try {
 Properties props = new Properties();
 InputStream in =
   getClass().getResourceAsStream(/conf/db.properties);
 props.load(in);
   ..
  
propertie1 = props.getProperty(propertie1);
  
C'ya
  
   Quoting Will Hartung [EMAIL PROTECTED]:
  
 From: [EMAIL PROTECTED]
 Subject: Loading Properties Files
   
   
 My problem is that the class cannot location my
   properties file. I am
 unable to
 use other suggested methods that I have noticed on this
   list since those
 problems
 involved Properties File within Servlets.

 After some testing, I determined for some reason the
   default directory it
 is looking
 for my properties file is the Windows System Directory
   (Determined this
by
 opening
 a file in the default directory, outputing something in
   it and searching
 for the file).

 Anyone have any ideas on how to solve this problem? I do
   not want to hard
 code the
 exact location due to obvious reasons
   
The problem is that you appear to be loading a file with an
   absolute path,
versus the common form of load a properties file

RE: Loading Properties Files

2002-12-04 Thread Craig R. McClanahan


On Wed, 4 Dec 2002, micael wrote:

 Date: Wed, 04 Dec 2002 17:13:16 -0800
 From: micael [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]
 Subject: RE: Loading Properties Files

 A .war file is just a wrapper for a web application.  I think he does not
 know what one is.  It is like a .zip or a .jar file.  Do you know that?


A WAR file has the same format as a JAR file, but a servlet container --
and most especially the class loader for a webapp that the a servlet
container provides -- very definitely *does* know where to look in a WAR
for unpacked classes/resources (in /WEB-INF/classes) or JAR files
containing classes/resources (in /WEB-INF/lib).  That's why Tomcat is
perfectly capable of running a webapp directly from a WAR, without
unpacking it.

As long as you use the correct resource paths (as shown in the examples),
you can access properties files under /WEB-INF/classes (or from JAR files
in /WEB-INF/classes).  These calls are required to work whether the WAR is
unpacked or not.

Craig


 At 06:56 PM 12/4/2002 -0600, you wrote:

 No, that's not true at all.
 
 The examples already given will find properties files for you just fine
 whether the file is in a directory structure or inside an archive.  How do
 you think Java loads classes?  It works out of archives, no?
 
 here are some various was to access a properties file ( or any resource,
 for that matter) in whether the app is deployed as a directory or as a
 .war file (even inside a .jar file in WEB-INF/lib)
 
 This will load a file in WEB-INF/classes/conf or any jar file in the
 classpath with a package of conf...
 getClass().getResourceAsStream(/conf/db.properties);
 
 This will load a file relative to the current class.  For instance, if the
 class is org.mypackage.MyClass, then the file would be loaded at
 org.mypackage.conf.dbproperties.  Note that this is because we didn't
 prepend / to the path.  When that is done, the file is loaded from the
 root of the current classloader where this loads it relative to the
 current class...
 getClass().getResourceAsStream(conf/db.properties);
 
 this will find db.properties anywhere in the current classloader as long
 as it exists in a conf package...
 getClass().getClassLoader().getResourceAsStream(conf/db.properties);
 
 
 This will find the file in a conf directory inside the webapp (starting
 from the root).  This starts looking in the same directory as contains
 WEB-INF.  When I say directory, I don't mean filesystem.  This could
 be in a .war file as well as in an actual directory on the filesystem...
 getServletContext().getResourceAsStream(/conf/db.properties);
 
 of course you would probably not want just anyone seeing your
 db.properties file, so you'd probably want to put in inside WEB-INF of
 your webapp, so
 getServletContext().getResourceAsStream(/WEB-INF/conf/db.properties);
 
 If your db.properties exists in another classloader which your app has
 access to, you can reach it by using:
 
Thread.currentThread().getContextClassLoader().getResourceAsStream(conf/db.properties);
 
 That will act similar to getClass().getClassLoader(), but it can see
 across all available classloaders where the latter can only see within the
 classloader that loaded the current class.
 
 So, as you can see, you have quite a number of options.  There you go.
 
 Jake
 
 At 03:37 PM 12/4/2002 -0800, you wrote:
 
 If I understand you correctly, the properties file CANNOT be in the war
 file, it needs to be external.  Right.
 
   -Original Message-
   From: micael [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, December 04, 2002 3:25 PM
   To: Tomcat Users List
   Subject: RE: Loading Properties Files
  
  
   Depends upon what you want to do with the properties files
   and how you
   access them.  Some ways of accessing them require that the
   name to access
   be relative to the classpath, others don't.  You are better
   off to learn
   about properties files in this instance.  There is nothing
   peculiar to the
   web-structure that I know of that is important about locating
   properties
   files.
  
   At 03:14 PM 12/4/2002 -0800, you wrote:
  
   And if you have a .war file?  Then where would you put your
   properties
   files?
   
 -Original Message-
 From: Roberto Bouza [mailto:[EMAIL PROTECTED]]
 Sent: Wednesday, December 04, 2002 2:49 PM
 To: Tomcat Users List
 Subject: Re: Loading Properties Files



  Thats right.

  If you don't have a .war file, you can use the classes dir
 inside your WEB-INF
 dir, and create a new directory like conf, the put inside
 all the properties
 files. In that way the ClassLoader looks for  the files in
 there when you use
 something like this:

   try {
   Properties props = new Properties();
   InputStream in =
 getClass().getResourceAsStream(/conf/db.properties

Re: Loading properties files

2002-08-27 Thread Alan Tingley - Iperia

Your properties file must be in a location that Tomcat knows about via its
classpath (WEB-INF/classes is on Tomcat's classpath, that's why it worked
when your file was there).  See the Tomcat docs under Classpath How-to,
which describes the class loaders in Tomcat.
Alan Tingley

- Original Message -
From: Laurent Michenaud [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 4:40 AM
Subject: Loading properties files


Hi,

Could u tell me what is not correct with that :

Before we had that ( the properties files were in WEB-INF/classes ) and
that works :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(db).getString(schema);
}


Now we want to have properties files in WEB-INF/config so we change
the file like this :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getString(sche
ma);
}

But it doesnot work, it can't find the db.properties. I have tried with
WEB-INF/config/db and /WEB-INF/config/db.properties but
it doesnot work too.

Can u tell me what's wrong ?




Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading properties files

2002-08-27 Thread randie ursal

why is it tomcat could not locate the property file if i place it on the
package directory structure of my servlets?...it is still on the 
WEB-INF/classes
directory isnt it? just need some more clarifications.

e.g  WEB-INF/classess/com/test/MyProperty.properties

thanks

Alan Tingley - Iperia wrote:

Your properties file must be in a location that Tomcat knows about via its
classpath (WEB-INF/classes is on Tomcat's classpath, that's why it worked
when your file was there).  See the Tomcat docs under Classpath How-to,
which describes the class loaders in Tomcat.
Alan Tingley

- Original Message -
From: Laurent Michenaud [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 4:40 AM
Subject: Loading properties files


Hi,

Could u tell me what is not correct with that :

Before we had that ( the properties files were in WEB-INF/classes ) and
that works :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(db).getString(schema);
}


Now we want to have properties files in WEB-INF/config so we change
the file like this :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getString(sche
ma);
}

But it doesnot work, it can't find the db.properties. I have tried with
WEB-INF/config/db and /WEB-INF/config/db.properties but
it doesnot work too.

Can u tell me what's wrong ?




Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]



  



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Loading properties files

2002-08-27 Thread Laurent Michenaud

I can't find the documentation u speak about.

Could u give me the url ?

 -Message d'origine-
 De : Alan Tingley - Iperia [mailto:[EMAIL PROTECTED]]
 Envoyé : mardi 27 août 2002 12:15
 À : Tomcat Users List
 Objet : Re: Loading properties files
 
 
 Your properties file must be in a location that Tomcat knows 
 about via its
 classpath (WEB-INF/classes is on Tomcat's classpath, that's 
 why it worked
 when your file was there).  See the Tomcat docs under 
 Classpath How-to,
 which describes the class loaders in Tomcat.
 Alan Tingley
 
 - Original Message -
 From: Laurent Michenaud [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, August 27, 2002 4:40 AM
 Subject: Loading properties files
 
 
 Hi,
 
 Could u tell me what is not correct with that :
 
 Before we had that ( the properties files were in 
 WEB-INF/classes ) and
 that works :
 
 package com.a2a.util ;
 public interface A2aConstantes
 {
   public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(db).getString(schema);
 }
 
 
 Now we want to have properties files in WEB-INF/config so we change
 the file like this :
 
 package com.a2a.util ;
 public interface A2aConstantes
 {
   public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getSt
 ring(sche
 ma);
 }
 
 But it doesnot work, it can't find the db.properties. I have 
 tried with
 WEB-INF/config/db and /WEB-INF/config/db.properties but
 it doesnot work too.
 
 Can u tell me what's wrong ?
 
 
 
 
 Michenaud Laurent
 - Adeuza -
 [ Développeur Web - Administrateur Réseau ]
 
 
 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 
 
 
 --
 To unsubscribe, e-mail:   
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: 
 mailto:[EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading properties files

2002-08-27 Thread Alan Tingley - Iperia

try http://jakarta.apache.org/tomcat/tomcat-4.1-doc/class-loader-howto.html
Al

- Original Message -
From: Laurent Michenaud [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Cc: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 7:09 AM
Subject: RE: Loading properties files


I can't find the documentation u speak about.

Could u give me the url ?

 -Message d'origine-
 De : Alan Tingley - Iperia [mailto:[EMAIL PROTECTED]]
 Envoyé : mardi 27 août 2002 12:15
 À : Tomcat Users List
 Objet : Re: Loading properties files


 Your properties file must be in a location that Tomcat knows
 about via its
 classpath (WEB-INF/classes is on Tomcat's classpath, that's
 why it worked
 when your file was there).  See the Tomcat docs under
 Classpath How-to,
 which describes the class loaders in Tomcat.
 Alan Tingley

 - Original Message -
 From: Laurent Michenaud [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, August 27, 2002 4:40 AM
 Subject: Loading properties files


 Hi,

 Could u tell me what is not correct with that :

 Before we had that ( the properties files were in
 WEB-INF/classes ) and
 that works :

 package com.a2a.util ;
 public interface A2aConstantes
 {
   public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(db).getString(schema);
 }


 Now we want to have properties files in WEB-INF/config so we change
 the file like this :

 package com.a2a.util ;
 public interface A2aConstantes
 {
   public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getSt
 ring(sche
 ma);
 }

 But it doesnot work, it can't find the db.properties. I have
 tried with
 WEB-INF/config/db and /WEB-INF/config/db.properties but
 it doesnot work too.

 Can u tell me what's wrong ?




 Michenaud Laurent
 - Adeuza -
 [ Développeur Web - Administrateur Réseau ]


 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]



 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading properties files

2002-08-27 Thread Glenn Nielsen

java.util.ResourceBundle.getBundle() uses the current ClassLoader to load
your resource bundle.  That means that your properties have to either be
located with a jar file in /WEB-INF/lib or in your /WEB-INF/classess directory.

This isn't a limitation of Tomcat, this is how resource bundles work.

Regards,

Glenn

randie ursal wrote:
 why is it tomcat could not locate the property file if i place it on the
 package directory structure of my servlets?...it is still on the 
 WEB-INF/classes
 directory isnt it? just need some more clarifications.
 
 e.g  WEB-INF/classess/com/test/MyProperty.properties
 
 thanks
 
 Alan Tingley - Iperia wrote:
 
 Your properties file must be in a location that Tomcat knows about via 
 its
 classpath (WEB-INF/classes is on Tomcat's classpath, that's why it worked
 when your file was there).  See the Tomcat docs under Classpath How-to,
 which describes the class loaders in Tomcat.
 Alan Tingley

 - Original Message -
 From: Laurent Michenaud [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Sent: Tuesday, August 27, 2002 4:40 AM
 Subject: Loading properties files


 Hi,

 Could u tell me what is not correct with that :

 Before we had that ( the properties files were in WEB-INF/classes ) and
 that works :

 package com.a2a.util ;
 public interface A2aConstantes
 {
  public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(db).getString(schema);
 }


 Now we want to have properties files in WEB-INF/config so we change
 the file like this :

 package com.a2a.util ;
 public interface A2aConstantes
 {
  public static final String SCHEMA =
 java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getString(sche
 ma);
 }

 But it doesnot work, it can't find the db.properties. I have tried with
 WEB-INF/config/db and /WEB-INF/config/db.properties but
 it doesnot work too.

 Can u tell me what's wrong ?




 Michenaud Laurent
 - Adeuza -
 [ Développeur Web - Administrateur Réseau ]


 -- 
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]



 -- 
 To unsubscribe, e-mail:   
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: 
 mailto:[EMAIL PROTECTED]



  

 
 
 -- 
 To unsubscribe, e-mail:   
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: 
 mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Loading properties files

2002-08-27 Thread Laurent Michenaud

So, how can i modify my interface so that it reads
the file properties db in WEB-INF/config ?

 -Message d'origine-
 De : Glenn Nielsen [mailto:[EMAIL PROTECTED]]
 Envoyé : mardi 27 août 2002 15:32
 À : Tomcat Users List
 Objet : Re: Loading properties files
 
 
 java.util.ResourceBundle.getBundle() uses the current 
 ClassLoader to load
 your resource bundle.  That means that your properties have 
 to either be
 located with a jar file in /WEB-INF/lib or in your 
 /WEB-INF/classess directory.
 
 This isn't a limitation of Tomcat, this is how resource bundles work.
 
 Regards,
 
 Glenn
 
 randie ursal wrote:
  why is it tomcat could not locate the property file if i 
 place it on the
  package directory structure of my servlets?...it is still on the 
  WEB-INF/classes
  directory isnt it? just need some more clarifications.
  
  e.g  WEB-INF/classess/com/test/MyProperty.properties
  
  thanks
  
  Alan Tingley - Iperia wrote:
  
  Your properties file must be in a location that Tomcat 
 knows about via 
  its
  classpath (WEB-INF/classes is on Tomcat's classpath, 
 that's why it worked
  when your file was there).  See the Tomcat docs under 
 Classpath How-to,
  which describes the class loaders in Tomcat.
  Alan Tingley
 
  - Original Message -
  From: Laurent Michenaud [EMAIL PROTECTED]
  To: [EMAIL PROTECTED]
  Sent: Tuesday, August 27, 2002 4:40 AM
  Subject: Loading properties files
 
 
  Hi,
 
  Could u tell me what is not correct with that :
 
  Before we had that ( the properties files were in 
 WEB-INF/classes ) and
  that works :
 
  package com.a2a.util ;
  public interface A2aConstantes
  {
   public static final String SCHEMA =
  java.util.ResourceBundle.getBundle(db).getString(schema);
  }
 
 
  Now we want to have properties files in WEB-INF/config so we change
  the file like this :
 
  package com.a2a.util ;
  public interface A2aConstantes
  {
   public static final String SCHEMA =
  
 java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getSt
 ring(sche
  ma);
  }
 
  But it doesnot work, it can't find the db.properties. I 
 have tried with
  WEB-INF/config/db and /WEB-INF/config/db.properties but
  it doesnot work too.
 
  Can u tell me what's wrong ?
 
 
 
 
  Michenaud Laurent
  - Adeuza -
  [ Développeur Web - Administrateur Réseau ]
 
 
  -- 
  To unsubscribe, e-mail:
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail:
  mailto:[EMAIL PROTECTED]
 
 
 
  -- 
  To unsubscribe, e-mail:   
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail: 
  mailto:[EMAIL PROTECTED]
 
 
 
   
 
  
  
  -- 
  To unsubscribe, e-mail:   
  mailto:[EMAIL PROTECTED]
  For additional commands, e-mail: 
  mailto:[EMAIL PROTECTED]
 
 
 
 
 --
 To unsubscribe, e-mail:   
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: 
 mailto:[EMAIL PROTECTED]
 
 

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading properties files

2002-08-27 Thread Alan Tingley - Iperia

we're using something like (off the top of my head):

System.getResourceAsStream(com/domain/package/file.properties)

and that works; until we fixed our app deployment structure, we had to use
getSystemResourceAsStream (we were putting things in common/lib when we
shouldn't have).
Al

- Original Message -
From: randie ursal [EMAIL PROTECTED]
To: Tomcat Users List [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 7:05 AM
Subject: Re: Loading properties files


why is it tomcat could not locate the property file if i place it on the
package directory structure of my servlets?...it is still on the
WEB-INF/classes
directory isnt it? just need some more clarifications.

e.g  WEB-INF/classess/com/test/MyProperty.properties

thanks

Alan Tingley - Iperia wrote:

Your properties file must be in a location that Tomcat knows about via
its
classpath (WEB-INF/classes is on Tomcat's classpath, that's why it
worked
when your file was there).  See the Tomcat docs under Classpath
How-to,
which describes the class loaders in Tomcat.
Alan Tingley

- Original Message -
From: Laurent Michenaud [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 4:40 AM
Subject: Loading properties files


Hi,

Could u tell me what is not correct with that :

Before we had that ( the properties files were in WEB-INF/classes ) and
that works :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(db).getString(schema);
}


Now we want to have properties files in WEB-INF/config so we change
the file like this :

package com.a2a.util ;
public interface A2aConstantes
{
  public static final String SCHEMA =
java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getString(sch
e
ma);
}

But it doesnot work, it can't find the db.properties. I have tried with
WEB-INF/config/db and /WEB-INF/config/db.properties but
it doesnot work too.

Can u tell me what's wrong ?




Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]







--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Loading properties files

2002-08-27 Thread Craig R. McClanahan



On Tue, 27 Aug 2002, Laurent Michenaud wrote:

 Date: Tue, 27 Aug 2002 15:43:29 +0200
 From: Laurent Michenaud [EMAIL PROTECTED]
 Reply-To: Tomcat Users List [EMAIL PROTECTED]
 To: Tomcat Users List [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: Loading properties files

 So, how can i modify my interface so that it reads
 the file properties db in WEB-INF/config ?

You can't.

Well, technically you can -- by modifying Tomcat's source code to violate
the servlet specification -- but then you'd be tied to your own version of
Tomcat now and forevermore, which is not a good idea.

Either put your properties files in /WEB-INF/classes instead, or implement
your own subclass of ResourceBundle that does what you want.

Craig


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Loading properties files

2002-08-27 Thread Glenn Nielsen

Why do you insist on putting your property file in /WEB-INF/config?

Just create a jar with your property file and put it in /WEB-INF/lib,
or put the property file in /WEB-INF/classes.

Regards,

Glenn

Laurent Michenaud wrote:
 So, how can i modify my interface so that it reads
 the file properties db in WEB-INF/config ?
 
 
-Message d'origine-
De : Glenn Nielsen [mailto:[EMAIL PROTECTED]]
Envoyé : mardi 27 août 2002 15:32
À : Tomcat Users List
Objet : Re: Loading properties files


java.util.ResourceBundle.getBundle() uses the current 
ClassLoader to load
your resource bundle.  That means that your properties have 
to either be
located with a jar file in /WEB-INF/lib or in your 
/WEB-INF/classess directory.

This isn't a limitation of Tomcat, this is how resource bundles work.

Regards,

Glenn

randie ursal wrote:

why is it tomcat could not locate the property file if i 

place it on the

package directory structure of my servlets?...it is still on the 
WEB-INF/classes
directory isnt it? just need some more clarifications.

e.g  WEB-INF/classess/com/test/MyProperty.properties

thanks

Alan Tingley - Iperia wrote:


Your properties file must be in a location that Tomcat 

knows about via 

its
classpath (WEB-INF/classes is on Tomcat's classpath, 

that's why it worked

when your file was there).  See the Tomcat docs under 

Classpath How-to,

which describes the class loaders in Tomcat.
Alan Tingley

- Original Message -
From: Laurent Michenaud [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Tuesday, August 27, 2002 4:40 AM
Subject: Loading properties files


Hi,

Could u tell me what is not correct with that :

Before we had that ( the properties files were in 

WEB-INF/classes ) and

that works :

package com.a2a.util ;
public interface A2aConstantes
{
 public static final String SCHEMA =
java.util.ResourceBundle.getBundle(db).getString(schema);
}


Now we want to have properties files in WEB-INF/config so we change
the file like this :

package com.a2a.util ;
public interface A2aConstantes
{
 public static final String SCHEMA =


java.util.ResourceBundle.getBundle(/WEB-INF/config/db).getSt
ring(sche

ma);
}

But it doesnot work, it can't find the db.properties. I 

have tried with

WEB-INF/config/db and /WEB-INF/config/db.properties but
it doesnot work too.

Can u tell me what's wrong ?




Michenaud Laurent
- Adeuza -
[ Développeur Web - Administrateur Réseau ]


-- 
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]



-- 
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]



 



-- 
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]


 
 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]
 




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]