> The problem that has been hashed over and over is that classes loaded
> from jars in WEB-INF/lib or tomcat's lib don't see WEB-INF/lib or
> WEB-INF/classes.  There are no class loader games you can play to change
> this as far as I know.  Certainly Category's classloader won't help any
> here.
>
They don't see resources in the WEB-INF/lib directory, but the do see resources
in WEB-INF/classes and within their own jar within WEB-INF/lib. In tomcat3.2.x
this requires adding the Jdk12Interceptor request interceptor to the server.xml
config file to use the Java2 class loading:

<RequestInterceptor className="org.apache.tomcat.request.Jdk12Interceptor" />

Here is a test class I use to as part of the JBoss application server embeded Tomcat
setup. It looks for different log4j.properties files that have been placed at different
points in the deployed war classpath:

package org.jboss.test.web.util;
public class Util
{
    public static String getTime()
    {
        return new Date().toString();
    }
    public static URL configureLog4j()
    {
        ClassLoader loader = Thread.currentThread().getContextClassLoader();
        URL webPropsURL = loader.getResource("weblog4j.properties");
        URL web2PropsURL = loader.getResource("web2log4j.properties");
        URL propsURL = loader.getResource("log4j.properties");
        System.out.println("getResource('weblog4j.properties') via TCL = 
"+webPropsURL);
        System.out.println("getResource('web2log4j.properties') via TCL = 
"+web2PropsURL);
        System.out.println("getResource('log4j.properties') via TCL = "+propsURL);
        URL webPropsURL2 = Util.class.getResource("/weblog4j.properties");
        URL web2PropsURL2 = Util.class.getResource("/web2log4j.properties");
        URL propsURL2 = Util.class.getResource("/log4j.properties");
        System.out.println("getResource('/weblog4j.properties') via CL = 
"+webPropsURL2);
        System.out.println("getResource('web2log4j.properties') via CL = 
"+web2PropsURL2);
        System.out.println("getResource('/log4j.properties') via CL = "+propsURL2);
        return propsURL;
    }
}

The log4j.properties file is in a config directory that is in the classpath of the
JBoss application server, the weblog4j.properties is in the WEB-INF/classes
directory and the web2log4j.properties is in the WEB-INF/lib/util.jar at
the root level.

Output from this class when access by a servlet that is loaded on startup shows that
all properties files are found by both the Util classloader and the thread context
class loader which is the tomcat servlet class loader.

getResource('weblog4j.properties') via TCL =
jar:file:G:\tmp\JBoss-2.2.2_Tomcat-3.2.2\jboss\tmp\deploy\Default\jbosstest-web.ear\web1029\WEB-INF\lib\util.jar!/weblog4j.propertie
s
getResource('web2log4j.properties') via TCL =
file:G:\tmp\JBoss-2.2.2_Tomcat-3.2.2\jboss\tmp\deploy\Default\jbosstest-web.ear\web1029\WEB-INF\classes\web2log4j.properties
getResource('log4j.properties') via TCL = 
file:/G:/tmp/JBoss-2.2.2_Tomcat-3.2.2/jboss/conf/tomcat/log4j.properties
getResource('/weblog4j.properties') via CL =
jar:file:G:\tmp\JBoss-2.2.2_Tomcat-3.2.2\jboss\tmp\deploy\Default\jbosstest-web.ear\web1029\WEB-INF\lib\util.jar!/weblog4j.propertie
s
getResource('web2log4j.properties') via CL =
file:G:\tmp\JBoss-2.2.2_Tomcat-3.2.2\jboss\tmp\deploy\Default\jbosstest-web.ear\web1029\WEB-INF\classes\web2log4j.properties
getResource('/log4j.properties') via CL = 
file:/G:/tmp/JBoss-2.2.2_Tomcat-3.2.2/jboss/conf/tomcat/log4j.properties

Framework level classes like Category should be using the thread context class loader, 
but this
requires Java2.



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

Reply via email to