You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Brian Lee Yung Rowe <pu...@muxspace.com> on 2004/08/23 19:16:57 UTC

[logging] Invalid class loader hierarchy w/Ant+Hibernate+Logging (or the case of the unseen Log spectre)

Hi:

I'm using commons logging with Ant and Hibernate and am getting a class loader 
error which has me scratching my head. I'm sending to this list as I believe 
it to be a configuration issue with Logging as opposed to Hibernate. Evidence 
otherwise is certainly welcome.

First some background: I'm trying to run Hibernate's schema export taskdef via 
Ant. The versions of salient libraries are below:

Ant 1.6.1
Commons-Logging 1.0.4
Log4J 1.2.8
Hibernate 2.1

This is the error I'm getting:
--- Nested Exception ---
java.lang.ExceptionInInitializerError
        at 
net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:182)
        at 
net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
...
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.
at 
org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
        at 
org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)


I checked my classpath (with a home-grown utility) to verify that there is 
only one org.apache.commons.logging.Log class within all of the jars in the 
classpath. 

Running ant -diagnostic shows the ant-commons-logging.jar loaded via Ant. I 
removed this jar and got the same error.

Now the interesting part. I removed the commons-logging.jar from my classpath 
and now I get a 
java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
        at org.apache.tools.ant.Project.executeTarget(Project.java:1224)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)

which I take to mean that I truly have only one copy of the commons-logging 
package in my classpath. 

So why does logging think there's an additional version of Log visible?

Any ideas are greatly appreciated.

Regards,
Brian

-- 
 =====
Brian Lee Yung Rowe (President, Chief Architect)
Cenozoa Corporation
3 East 28th Street, 9th Floor, New York 10016
646 536 3066
www.cenozoa.com

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


Re: [logging] Invalid class loader hierarchy w/Ant+Hibernate+Logging (or the case of the unseen Log spectre)

Posted by brian lee yung rowe <pu...@muxspace.com>.
Hi Craig,

Thanks for the quick responses.

I'll see about digging into SchemaExportTask. I'm working on trying to call it 
explicitly via a <java> task as a workaround.

As for the Java system extensions directory, there is none, and I am using 
version 1.0.4 of commons logging.

Thanks,
Brian


On Tuesday 24 August 2004 12:45 pm, you wrote:
> It would be worth investigating what the SchemaExportTask code itself
> does.  It wouldn't surprise me if it built up its own class loaders
> somewhere.  Also, double check that you don't have a copy of Commons
> Logging in your Java system extensions directory
> ($JAVA_HOME/jre/lib/ext), and that you're using version 1.0.4 --
> previous versions had class loading issues that were resolved in the
> latest one.
>
> Craig
>
>
> On Tue, 24 Aug 2004 10:30:36 -0400, brian lee yung rowe
>
> <pu...@muxspace.com> wrote:
> > Hi:
> >
> > The target I'm using within Ant is below. Unfortunately, the fork
> > attribute is not allowed within taskdef elements. Also, I did check for
> > other instances of the org.apache.commons.logging.Log class within every
> > jar in my classpath; there happens to be one in Ant's lib (which is not
> > in my classpath), but even when I removed that, I received the same
> > error.
> >
> > As I said before, if I remove the commons-logging package, then I get a
> > NoClassDefFoundError, so if there were another instance of the class, why
> > would I get this error?
> >
> > <target name="schema" depends="init">
> >   <taskdef name="schemaexport"
> >      classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
> >      classpath="${java.class.path}:${src.conf}" />
> >
> >   <schemaexport
> >      properties="${src.conf}/hibernate.cfg.xml"
> >      quiet="no"
> >      text="no"
> >      drop="no"
> >      delimiter=";"
> >      output="schema-export.sql">
> >     <fileset dir="${src.conf}">
> >       <include name="**/*.hbm.xml"/>
> >     </fileset>
> >   </schemaexport>
> > </target>
> >
> > I am using a script that I wrote to check every Jar in the classpath for
> > the Log class, and the only one that shows up is in the commons logging
> > package. If you wish to see the script, I can post it in another email.
> >
> > Thanks,
> > Brian
> >
> > On Tuesday 24 August 2004 03:34 am, you wrote:
> > > On Mon, 23 Aug 2004 13:16:57 -0400, Brian Lee Yung Rowe
> > >
> > > <pu...@muxspace.com> wrote:
> > > > Hi:
> > > >
> > > > I'm using commons logging with Ant and Hibernate and am getting a
> > > > class loader error which has me scratching my head. I'm sending to
> > > > this list as I believe it to be a configuration issue with Logging as
> > > > opposed to Hibernate. Evidence otherwise is certainly welcome.
> > > >
> > > > First some background: I'm trying to run Hibernate's schema export
> > > > taskdef via Ant. The versions of salient libraries are below:
> > > >
> > > > Ant 1.6.1
> > > > Commons-Logging 1.0.4
> > > > Log4J 1.2.8
> > > > Hibernate 2.1
> > > >
> > > > This is the error I'm getting:
> > > > --- Nested Exception ---
> > > > java.lang.ExceptionInInitializerError
> > > >         at
> > > > net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(Schem
> > > >aExp ortTask.java:182) at
> > > > net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTa
> > > >sk.j ava:135) ....
> > > > 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.
> > >
> > > This message means what it says.
> > >
> > > If you have more than one version of org.apache.commons.logging.Log
> > > visible in the class path, you are pretty much guaranteed to have
> > > class loading issues, so the Commons Logging code tries to identify
> > > and catch this case as early as possible.
> > >
> > > When using Ant, I've found that it is almost always necessary to use a
> > > separate process for the actual application you are trying to run
> > > (such as using fork="true" on a <java> task), to avoid conficts
> > > between Ant's internal class loader (which includes, for example,
> > > everything in $ANT_HOME/lib) and the class path you have specified for
> > > that particular target.
> > >
> > > But there's no way to know what is actually going on for you, without
> > > more details about the Ant targets you are trying to execute.
> > >
> > > Craig
> >
> > --
> > "to disappear in the minds of others is inevitable"
> >  mux space dot com

-- 
"to disappear in the minds of others is inevitable"
 mux space dot com

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


Re: [logging] Invalid class loader hierarchy w/Ant+Hibernate+Logging (or the case of the unseen Log spectre)

Posted by brian lee yung rowe <pu...@muxspace.com>.
Hi:

The target I'm using within Ant is below. Unfortunately, the fork attribute is 
not allowed within taskdef elements. Also, I did check for other instances of 
the org.apache.commons.logging.Log class within every jar in my classpath; 
there happens to be one in Ant's lib (which is not in my classpath), but even 
when I removed that, I received the same error.

As I said before, if I remove the commons-logging package, then I get a 
NoClassDefFoundError, so if there were another instance of the class, why 
would I get this error?

<target name="schema" depends="init">
  <taskdef name="schemaexport"
     classname="net.sf.hibernate.tool.hbm2ddl.SchemaExportTask"
     classpath="${java.class.path}:${src.conf}" />

  <schemaexport
     properties="${src.conf}/hibernate.cfg.xml"
     quiet="no"
     text="no"
     drop="no"
     delimiter=";"
     output="schema-export.sql">
    <fileset dir="${src.conf}">
      <include name="**/*.hbm.xml"/>
    </fileset>
  </schemaexport>
</target>

I am using a script that I wrote to check every Jar in the classpath for the 
Log class, and the only one that shows up is in the commons logging package. 
If you wish to see the script, I can post it in another email.

Thanks,
Brian


On Tuesday 24 August 2004 03:34 am, you wrote:
> On Mon, 23 Aug 2004 13:16:57 -0400, Brian Lee Yung Rowe
>
> <pu...@muxspace.com> wrote:
> > Hi:
> >
> > I'm using commons logging with Ant and Hibernate and am getting a class
> > loader error which has me scratching my head. I'm sending to this list as
> > I believe it to be a configuration issue with Logging as opposed to
> > Hibernate. Evidence otherwise is certainly welcome.
> >
> > First some background: I'm trying to run Hibernate's schema export
> > taskdef via Ant. The versions of salient libraries are below:
> >
> > Ant 1.6.1
> > Commons-Logging 1.0.4
> > Log4J 1.2.8
> > Hibernate 2.1
> >
> > This is the error I'm getting:
> > --- Nested Exception ---
> > java.lang.ExceptionInInitializerError
> >         at
> > net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExp
> >ortTask.java:182) at
> > net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.j
> >ava:135) ....
> > 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.
>
> This message means what it says.
>
> If you have more than one version of org.apache.commons.logging.Log
> visible in the class path, you are pretty much guaranteed to have
> class loading issues, so the Commons Logging code tries to identify
> and catch this case as early as possible.
>
> When using Ant, I've found that it is almost always necessary to use a
> separate process for the actual application you are trying to run
> (such as using fork="true" on a <java> task), to avoid conficts
> between Ant's internal class loader (which includes, for example,
> everything in $ANT_HOME/lib) and the class path you have specified for
> that particular target.
>
> But there's no way to know what is actually going on for you, without
> more details about the Ant targets you are trying to execute.
>
> Craig

-- 
"to disappear in the minds of others is inevitable"
 mux space dot com

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


Re: [logging] Invalid class loader hierarchy w/Ant+Hibernate+Logging (or the case of the unseen Log spectre)

Posted by Craig McClanahan <cr...@gmail.com>.
On Mon, 23 Aug 2004 13:16:57 -0400, Brian Lee Yung Rowe
<pu...@muxspace.com> wrote:
> Hi:
> 
> I'm using commons logging with Ant and Hibernate and am getting a class loader
> error which has me scratching my head. I'm sending to this list as I believe
> it to be a configuration issue with Logging as opposed to Hibernate. Evidence
> otherwise is certainly welcome.
> 
> First some background: I'm trying to run Hibernate's schema export taskdef via
> Ant. The versions of salient libraries are below:
> 
> Ant 1.6.1
> Commons-Logging 1.0.4
> Log4J 1.2.8
> Hibernate 2.1
> 
> This is the error I'm getting:
> --- Nested Exception ---
> java.lang.ExceptionInInitializerError
>         at
> net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:182)
>         at
> net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
> ....
> 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.

This message means what it says.

If you have more than one version of org.apache.commons.logging.Log
visible in the class path, you are pretty much guaranteed to have
class loading issues, so the Commons Logging code tries to identify
and catch this case as early as possible.

When using Ant, I've found that it is almost always necessary to use a
separate process for the actual application you are trying to run
(such as using fork="true" on a <java> task), to avoid conficts
between Ant's internal class loader (which includes, for example,
everything in $ANT_HOME/lib) and the class path you have specified for
that particular target.

But there's no way to know what is actually going on for you, without
more details about the Ant targets you are trying to execute.

Craig

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


Re: [logging] Invalid class loader hierarchy w/Ant+Hibernate+Logging (or the case of the unseen Log spectre)

Posted by José Antonio Pérez Testa <ja...@indra.es>.
IMO the problem is still there because of some other jar in the classpath.
ant-commons-logging.jar only contains a class wrapper to commons-logging 
Log.
The actual implementation must be in a jar named commons-logging.jar 
somewhere in the classpath.

Regards.

Brian Lee Yung Rowe wrote:

>Hi:
>
>I'm using commons logging with Ant and Hibernate and am getting a class loader 
>error which has me scratching my head. I'm sending to this list as I believe 
>it to be a configuration issue with Logging as opposed to Hibernate. Evidence 
>otherwise is certainly welcome.
>
>First some background: I'm trying to run Hibernate's schema export taskdef via 
>Ant. The versions of salient libraries are below:
>
>Ant 1.6.1
>Commons-Logging 1.0.4
>Log4J 1.2.8
>Hibernate 2.1
>
>This is the error I'm getting:
>--- Nested Exception ---
>java.lang.ExceptionInInitializerError
>        at 
>net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.getConfiguration(SchemaExportTask.java:182)
>        at 
>net.sf.hibernate.tool.hbm2ddl.SchemaExportTask.execute(SchemaExportTask.java:135)
>...
>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.
>at 
>org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
>        at 
>org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
>
>
>I checked my classpath (with a home-grown utility) to verify that there is 
>only one org.apache.commons.logging.Log class within all of the jars in the 
>classpath. 
>
>Running ant -diagnostic shows the ant-commons-logging.jar loaded via Ant. I 
>removed this jar and got the same error.
>
>Now the interesting part. I removed the commons-logging.jar from my classpath 
>and now I get a 
>java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
>        at org.apache.tools.ant.Project.executeTarget(Project.java:1224)
>        at org.apache.tools.ant.Project.executeTargets(Project.java:1063)
>
>which I take to mean that I truly have only one copy of the commons-logging 
>package in my classpath. 
>
>So why does logging think there's an additional version of Log visible?
>
>Any ideas are greatly appreciated.
>
>Regards,
>Brian
>
>  
>
-------------------------------------------------------------------------------------------------------------------
Este correo electrónico y, en su caso, cualquier fichero anexo al mismo, contiene información de carácter confidencial exclusivamente dirigida a su destinatario o destinatarios. Queda prohibida su divulgación, copia o distribución a terceros sin la previa autorización escrita de Indra. En el caso de haber recibido este correo electrónico por error, se ruega notificar inmediatamente esta circunstancia mediante reenvío a la dirección electrónica del remitente.

The information in this e-mail and in any attachments is confidential and solely for the attention and use of the named addressee(s). You are hereby notified that any dissemination, distribution or copy of this communication is prohibited without the prior written consent of Indra. If you have received this communication in error, please, notify the sender by reply e-mail

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