Hello Maarten,

Interesting problem. However, I am not sure I understand it fully. First, which 
application server is this? JBoss? Weblogic? Orion? WebSphere? 

Second, what is the error generated by log4j? Is it the "log4j:WARN no appenders found 
..." message? 

At 10:07 08.08.2001 +0200, Maarten Coene wrote:
>Hi,
>
>there is a problem loading the default log4j.properties file when using J2EE (RI). My 
>system has the following configuration:
>1. the log4j.jar is placed into my CLASSPATH variable
>2. my log4j.properties file is placed into the classpath of my J2EE Application
>
>Now, if I try to create a new Category, log4j complains it cannot find the 
>log4j.properties file. This is because the log4j.jar is loaded with a different 
>classloader than my J2EE application: say classloaderA has loaded my log4j.jar file 
>and classloaderB has loaded my J2EE Application. ClassloaderA has no knowledge of my 
>J2EE application and therefore cannot find the log4j.properties file, but 
>classloaderB can find it since it is in it's classpath!!

Well, that is true only if classloaderB and classloaderA are not related in a 
parent/child relationship. Otherwise, if classloaderA is the parent of classloaderB, 
then classloaderB can and will delegate resource finding to it its parent. Hence, if 
classloaderA can see it, so can classloaderB (assuming a parent child relationship). 

Classloading problems are very tricky so I'd like to understand the problem before 
committing changes.

In any case, thank you for your informative message. Ceki


>I have solved this problem the same way the "loadClass problem" has been solved in 
>the org.apache.log4j.helpers.Loader class. I have replaced the following line of code 
>in the Loader.class:
>
>// Let the class loader of clazz and parents (by the delagation
>// property) seearch for resource
>ClassLoader loader = clazz.getClassLoader();
>
>by:
>
>// Let the class loader of clazz and parents (by the delagation
>// property) seearch for resource
>ClassLoader loader = null;
>
>if(java1) {
>  loader = clazz.getClassLoader();
>} else {
>  loader = Thread.currentThread().getContextClassLoader();
>}
>
>After this replacement, log4j can succesfully load my default log4j.properties file! 
>If you think it's ok, perhaps someone can commit it to cvs?
>
>Maarten
>
>--
>Maarten Coene
>Katholieke Universiteit Leuven
>Dept. Computerwetenschappen             Tel: ++32 (0)16/32 78 25
>Celestijnenlaan 200A
>B-3001 Heverlee

--
Ceki Gülcü - http://qos.ch


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

Reply via email to