Howdy,
Didn't I give the ClassLoader solution earlier today on another list? ;)

Anyways, as I mentioned there, I don't like classloading resource access because I 
don't like to put configuration information on the classpath.

Instead, put config.properties under your /WEB-INF directory.  Avoid file-based APIs 
as they don't work out of a WAR archive.  Use ServletContext's getResource() or 
getResourceAsStream() instead:

For log4j property configuration:
PropertyConfigurator.configure(getServletContext().getResource("/WEB-INF/config.properties"));

Or generally to load properties:
InputStream is = getServletContext().getResourceAsStream("/WEB-INF/config.properties");
props.load(is);

Yoav Shapira
Millennium ChemInformatics


>-----Original Message-----
>From: Jos� Moreira [mailto:[EMAIL PROTECTED]
>Sent: Wednesday, February 26, 2003 11:31 AM
>To: Tomcat Users List
>Subject: RE: Properties file [SOLVED?]
>
>still didnt work ...
>
>my code :\
>
>String path =
>this.getClass().getClassLoader().getResource("config.properties").getPath()
>.
>toString();
>
>FileInputStream in = new FileInputStream(path);
>
>properties.load(in);
>
>
>
>-----Mensagem original-----
>De: Jacob Kjome [mailto:[EMAIL PROTECTED]
>Enviada: quarta-feira, 26 de Fevereiro de 2003 15:35
>Para: Tomcat Users List
>Assunto: Re: Properties file [SOLVED?]
>
>
>
>Why don't you just load the properties file as an inputstream.  If you get
>the path and then use that for a File object, you are making your webapp
>non-portable.  If your webapp is served directly from a .war file, you
>won't have the ability do perform File IO.  Use streams and URL's and you
>will be fine.
>
>Jake
>
>At 03:24 PM 2/26/2003 +0000, you wrote:
>>i copied the 'config.properties' file to WEB-INF\classes and accessed it
>>from inside a bean using
>>
>>
>>this.getClass().getClassLoader().getResource("config.properties").getPath(
>)
>.
>>toString()
>>
>>ang got
>>
>>         N:/webapps/Java/Project/WEB-INF/classes/config.properties
>>
>>i hope the is no downside to this
>>
>>cheers
>>
>>good work
>>
>>
>>---------------<*>----------------------
>>Jos� Moreira
>>
>>T�cnico de Inform�tica | IT Technician
>>
>>Vila Nova de Gaia, Portugal
>>
>>E-Mail: [EMAIL PROTECTED]
>>
>>MSN: [EMAIL PROTECTED]
>>
>>ICQ: 136936120
>>
>>IRC: ethernal (irc.ptnet.org)
>>
>>
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: [EMAIL PROTECTED]
>>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]




This e-mail, including any attachments, is a confidential business communication, and 
may contain information that is confidential, proprietary and/or privileged.  This 
e-mail is intended only for the individual(s) to whom it is addressed, and may not be 
saved, copied, printed, disclosed or used by anyone else.  If you are not the(an) 
intended recipient, please immediately delete this e-mail from your computer system 
and notify the sender.  Thank you.


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

Reply via email to