Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > ClassLoader.getResourceAsStream

Reply
Thread Tools

ClassLoader.getResourceAsStream

 
 
F C
Guest
Posts: n/a
 
      11-06-2003
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
 
Reply With Quote
 
 
 
 
Alain Javier Guarnieri del Gesu
Guest
Posts: n/a
 
      11-07-2003
* F C <(E-Mail Removed)>:
> 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");
 
Reply With Quote
 
 
 
 
gpenia gpenia is offline
Junior Member
Join Date: Mar 2009
Posts: 1
 
      03-31-2009
Hi,

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

G
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments