ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Herman, Dave" <>
Subject ClassLoader: log4j 1.2 in JUnit tests
Date Fri, 18 Jan 2002 21:35:39 GMT

I'm not sure if this is more appropriate in the log4j mailing list, but
hopefully it's relevant here.

I'm using log4j 1.2alpha6 and my JUnit tests, when run via Ant 1.4.1, are
failing to log correctly. I've figured out that the default class loader
that Ant is using is different from the one log4j is using when configuring
appenders from a properties file.

The log4j FAQ says that they're using the Java 2 "preferred method for
loading classes" now:


Unfortunately, the context class loader for the current thread is not the
Ant class loader but rather the built-in JRE class loader. What I'm getting

    log4j:ERROR: A "foo.mumble.MyAppender" object is not assignable
                 to a "org.apache.log4j.Appender" variable.

Sure enough, from looking at the code, the older log4j 1.1.3 just uses
Class.forName() to load the classes, which works, but the newer one uses the
syntax above, which doesn't.

Has anyone had this problem? Is there a way around this? Thanks so much in

Dave H

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message