You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Kurt Guenther <ku...@serent.com> on 2005/09/29 20:22:30 UTC

logging: more then one version of 'org.apache.commons.logging.Log' visible

I'm using 1.0.4 of commons-logging. 

I'm getting this error from the LogFactory.getLog() method.  It complains about: 

    [junit] Caused by: 
org.apache.commons.logging.LogConfigurationException: 
org.apache.commons.logging.LogConfigurationException: Invalid class 
loader hierarchy.  You have more than one version of 
'org.apache.commons.logging.Log' visible, which is not allowed.

But, I've checked the classpath very carefully and the only 
'org.apache.commons.logging.Log' is in the common-logging.jar file and 
there's only one of these.   I even tried the "javap -classpath 
list:of:paths  org.apache.commons.logging.Log" trick.   There's 
definitely a copy in the classpath and when I remove the commons-logging 
jar, the class is no longer defined.

The real kicker is this only occurs when I'm using the swing UI of Junit.  If I use the Text UI or use the Junit Eclipse plug-in, it works perfectly fine.  

Could there be something about the swing UI class loader that's creating problems? 

--Kurt





---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Kurt Guenther <ku...@serent.com>.
Jason Vinson wrote:

> Can you not pass args like this to your swing ui:
>
>-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y
>
>This will allow you to connect as a "remote application" in the eclipse
>debugger.
>
>  
>

I forgot about that.  I refreshed by jdb skills instead.  :-(



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Jason Vinson <vi...@charter.net>.
On 10/1/05 10:22 AM, "Kurt Guenther" <ku...@serent.com> wrote:

> I downloaded the commons-logging source, but it's rough sledding because
> I can't use the eclipse debugger.
> 

Can you not pass args like this to your swing ui:

-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y

This will allow you to connect as a "remote application" in the eclipse
debugger.

Hope this helps,
Jason



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Kurt Guenther <ku...@serent.com>.
Simon Kitching wrote:

>I bet you *will* find that there are multiple copies of Log available.
>  
>

I wish it were true.  I inserted this:

            ClassLoader cl = Thread.currentThread().getContextClassLoader();
            Enumeration logs =
               cl.getResources("org/apache/commons/logging/Log.class");
            while (logs.hasMoreElements()) {
                URL url = (URL) logs.nextElement();
                System.out.println("URL=" + url.toString());
            }

And, only have this as output.

URL=jar:file:/home/kurtg/work/panoscopix/svn/tools/java/apache/jakarta/commons/logging/1.0.4/commons-logging.jar!/org/apache/commons/logging/Log.class

I downloaded the commons-logging source, but it's rough sledding because 
I can't use the eclipse debugger.

--Kurt


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Kurt Guenther <ku...@serent.com>.
Kurt Guenther wrote:

>
> Here's the deal.  I can't explain it, but this is what's happening:
>
> In org/apache/commons/logging/impl/LogFactoryImpl.java around line 
> #360 is the method getLogConstructor():
>
>    logClassName=org.apache.commons.logging.impl.Log4JLogger
>    logInterface=org.apache.commons.logging.Log
>
> However, this is returning false:
>
>    logInterface.isAssignableFrom(logClassName)
>
> which doesn't seem right.   Then checks interfaces and indeeed,  
> org.apache.commons.logging.Log is an interface of 
> org.apache.commons.logging.impl.Log4JLogger, so I get the exception:
>
> org.apache.commons.logging.LogConfigurationException: Invalid class 
> loader hierarchy.  You have more than one version of 
> 'org.apache.commons.logging.Log' visible, which is not allowed.
>
> It almost seems like a JDK error, but I couldn't find any open bugs on 
> this.
>
> --Kurt
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
>

I should mention that I'm running:

Linux seeker 2.6.13-gentoo-r2
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_09-b05)

Again, this only occurs when I run the Junit Swing UI.  I have no 
problems with the TextUI.

--Kurt



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Kurt Guenther <ku...@serent.com>.
Here's the deal.  I can't explain it, but this is what's happening:

In org/apache/commons/logging/impl/LogFactoryImpl.java around line #360 
is the method getLogConstructor():

    logClassName=org.apache.commons.logging.impl.Log4JLogger
    logInterface=org.apache.commons.logging.Log

However, this is returning false:

    logInterface.isAssignableFrom(logClassName)

which doesn't seem right.   Then checks interfaces and indeeed,  
org.apache.commons.logging.Log is an interface of 
org.apache.commons.logging.impl.Log4JLogger, so I get the exception:

org.apache.commons.logging.LogConfigurationException: Invalid class 
loader hierarchy.  You have more than one version of 
'org.apache.commons.logging.Log' visible, which is not allowed.

It almost seems like a JDK error, but I couldn't find any open bugs on 
this.

--Kurt


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: logging: more then one version of 'org.apache.commons.logging.Log' visible

Posted by Simon Kitching <sk...@apache.org>.
On Thu, 2005-09-29 at 14:22 -0400, Kurt Guenther wrote:
> I'm using 1.0.4 of commons-logging. 
> 
> I'm getting this error from the LogFactory.getLog() method.  It complains about: 
> 
>     [junit] Caused by: 
> org.apache.commons.logging.LogConfigurationException: 
> org.apache.commons.logging.LogConfigurationException: Invalid class 
> loader hierarchy.  You have more than one version of 
> 'org.apache.commons.logging.Log' visible, which is not allowed.
> 
> But, I've checked the classpath very carefully and the only 
> 'org.apache.commons.logging.Log' is in the common-logging.jar file and 
> there's only one of these.   I even tried the "javap -classpath 
> list:of:paths  org.apache.commons.logging.Log" trick.   There's 
> definitely a copy in the classpath and when I remove the commons-logging 
> jar, the class is no longer defined.
> 
> The real kicker is this only occurs when I'm using the swing UI of Junit.  If I use the Text UI or use the Junit Eclipse plug-in, it works perfectly fine.  
> 
> Could there be something about the swing UI class loader that's creating problems? 

junit does set up some odd classpaths when running tests.

You could try putting this code just before your call to
LogFactory.getLog():

ClassLoader cl = Thread.currentThread().getContextClassLoader();
Enumeration logs =
   cl.getResources("org/apache/commons/logging/Log.class");
// print out the contents of the logs enumeration

I bet you *will* find that there are multiple copies of Log available.

Regards,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org