Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   ClassLoader.getResourceAsStream (http://www.velocityreviews.com/forums/t128421-classloader-getresourceasstream.html)

F C 11-06-2003 04:23 PM

ClassLoader.getResourceAsStream
 
Bonjour

I checked the newgroups before to send a message.

I need to read the logging configuration from a file.

LogManager.getLogManager().readConfiguration(
getClass().getClassLoader().getResourceAsStream(co nfigFile)
);

This instruction is executed from a data server running in a tomcat
4.0.1 instance.
The data server is in a jar file.

Unfortunately, the three following commands to get an InputStream
instance associated to the configuration file return a null reference:

command a) getClass().getResourceAsStream(configFile)
command b) getClass().getClassLoader().getResourceAsStream(co nfigFile)
command c) Thread.currentThread().getContextClassLoader().get ResourceAsStream(configFile)

But, in an application mode (i.e. data server not running in a tomcat
server)
only the previous command a) return null.

Does some one have an idea how can i get an input stream corresponding
to the configuration file ?

I use java 1.4.0 under solaris ( I also tried with java 1.4.1).

Thank you for your help
F

Alain Javier Guarnieri del Gesu 11-07-2003 10:29 PM

Re: ClassLoader.getResourceAsStream
 
* F C <do_not_reply_please@yahoo.fr>:
> I need to read the logging configuration from a file.
>
> The data server is in a jar file.
>
> Unfortunately, the three following commands to get an InputStream
> instance associated to the configuration file return a null reference:
>
> command a) getClass().getResourceAsStream(configFile)
> command b) getClass().getClassLoader().getResourceAsStream(co nfigFile)
> command c) Thread.currentThread().getContextClassLoader().get ResourceAsStream(configFile)


package fr.yahoo.do_not_reply_please;

class France {
public void bonjour () {

InputStream in = getClass().getResourceAsStream("data.txt");

gpenia 03-31-2009 08:43 AM

Try with antiJARLocking property
 
Hi,

I put property antiJARLocking as "true" in the context.xml file and starts getting resources from JARS:
<Context path="/teller" antiJARLocking="true"/>

G


All times are GMT. The time now is 06:40 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.