commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [logging] ClassCastException/InstantiationException from LogFactory.newFactory()
Date Mon, 27 Sep 2004 07:52:29 GMT
On Mon, 2004-09-27 at 18:57, Nicholas Gianniotis wrote: 
> Hi,
> I'm working with jwsdp-1.1, commons-logging (1.0.3, 1.0.4) and log4j
> (1.2.7, 1.2.8) on a Solaris x86 (SunOS 5.8) platform with the Java
> j2sdk1.4.2_04 environment.
> When Tomcat comes up with the jwsdp out-of-the-box configuration,
> org.apache.commons.logging.LogFactory() seems to choose
> org.apache.commons.logging.impl.SimpleLog as the default logging
> implementation.
> I'm trying to get it to use Log4JLogger instead, but can't seem to be
> able to.
> Following the instructions "Choosing A LogFactory Implementation" in
> the docs, I created a properties file named
> visible in the application class path and defined the property
> org.apache.commons.logging.LogFactory=Log4JLogger.
> When I restart Tomcat ( run), I get a
> org.apache.commons.logging.LogConfigurationException:
> java.lang.ClassCastException (full stack trace appended). I tried
> several other implementation classes like Jdk14Logger, and there I got
> similar errors: org.apache.commons.logging.LogConfigurationException:
> java.lang.InstantiationException:
> org.apache.commons.logging.impl.Jdk14Logger.

You're probably running into a common problem where you have multiple
copies of Log4J in your classpath.

This can lead to situations where (for example) Log4jLogger is loaded by
classloader A, and it "implements" interface o.a.c.l.Log as loader by
classloader A. However you can't cast the Log4jLogger object to a
"reference-to-o.a.c.l.Log as loaded by classloader B", becauses
classes/interfaces loaded by different classloaders are incompatible.

This is a fairly common problem; you should find some help on the log4j
web pages, or in the log4j FAQ.




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

View raw message