Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 92179 invoked from network); 29 Dec 2009 17:10:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 29 Dec 2009 17:10:57 -0000 Received: (qmail 36373 invoked by uid 500); 29 Dec 2009 17:10:56 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 36264 invoked by uid 500); 29 Dec 2009 17:10:56 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 36254 invoked by uid 99); 29 Dec 2009 17:10:56 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2009 17:10:56 +0000 X-ASF-Spam-Status: No, hits=-10.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 29 Dec 2009 17:10:49 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 67627234C045 for ; Tue, 29 Dec 2009 09:10:29 -0800 (PST) Message-ID: <1973813765.1262106629409.JavaMail.jira@brutus.apache.org> Date: Tue, 29 Dec 2009 17:10:29 +0000 (UTC) From: "Dennis Lundberg (JIRA)" To: issues@commons.apache.org Subject: [jira] Updated: (LOGGING-45) Default LogFactory Implementation fails for Log4J : ClassCastException MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/LOGGING-45?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Dennis Lundberg updated LOGGING-45: ----------------------------------- Fix Version/s: 1.0.3 > Default LogFactory Implementation fails for Log4J : ClassCastException > ---------------------------------------------------------------------- > > Key: LOGGING-45 > URL: https://issues.apache.org/jira/browse/LOGGING-45 > Project: Commons Logging > Issue Type: Bug > Affects Versions: 1.0 > Environment: Operating System: other > Platform: Other > Reporter: Jerome Jacobsen > Fix For: 1.0.3 > > > I've got Log4J 1.1.3 JAR in my classpath. Upon startup of my application > (actually a JUnit test case), I immediately get: > java.lang.ExceptionInInitializerError: > org.apache.commons.logging.LogConfigurationException: > java.lang.ClassCastException > So I downloaded the Commons Logging 1.0 source and debugged. The problem is in > org.apache.commons.logging.impl.LogFactoryImpl.guessConfig(). > Class proxyClass=findClassLoader(). > loadClass( "org.apache.commons.logging.Log4jFactory" ); > The above loadClass call should be changed to: > Class proxyClass=findClassLoader(). > loadClass( "org.apache.commons.logging.impl.Log4jFactory" ); > However, after I make the above change I still get a ClassCastException, now > from org.apache.commons.logging.LogFactory.newFactory(). This exception > baffles me. It happens at: > return (LogFactory) clazz.newInstance(); > So I modify newFactory() to do the newInstance() and the return in two steps > instead of one. > Object result = clazz.newInstance(); > return (LogFactory)result; > The exception occurs during the cast of result. If I print result's class name > I get org.apache.commons.logging.impl.LogFactoryImpl. But checking if result > is an instanceof org.apache.commons.logging.impl.LogFactoryImpl returns false. > Object result = clazz.newInstance(); > System.out.println("Got Factory: " + result.getClass().getName()); > if (result instanceof LogFactory) { > System.out.println("result is a LogFactory"); > } > if (result instanceof org.apache.commons.logging.impl.LogFactoryImpl) { > System.out.println("result is a LogFactoryImpl"); > } > return (LogFactory) result; > The code above just prints: > Got Factory: org.apache.commons.logging.impl.LogFactoryImpl > And then throws the ClassCastException. I'm confused. -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.