-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Oren,

Oren Livne wrote:
> - $tomcat_home/lib contains: (I copied the Struts and Hibernate libs
> over here)

Why did you do this? Unless you have a /really/ good reason, all of the
libs required for your webapp should be in $YOUR_APP/WEB-INF/lib. Get
all of that Struts and Hibernate stuff out of Tomcat's server libs.

> java.lang.NoClassDefFoundError: org/apache/log4j/Category
> java.lang.Class.getDeclaredConstructors0(Native Method)
> java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
> java.lang.Class.getConstructor0(Class.java:2699)
> java.lang.Class.getConstructor(Class.java:1657)
> org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
> 
> org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
> 
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
> 
> org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
> 
> org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
> org.apache.struts.util.MessageResources.<clinit>(MessageResources.java:54)

Nobody seems to believe us whenever we say "classes loaded by one
classloader cannot see classes loaded by another (unrelated)
classloader". It's true!

The commons-logging classes are loaded by one of the server's
classloaders (because you have them in $CATALINA_HOME/lib or whatever).
The log4j classes are loaded by your webapp's classloader (because they
are in $YOUR_APP/WEB-INF/lib). Therefore, commons-logging cannot create
instances of the log4j classes loaded by that other classloader.

The "Tomcat 6 Logging" page
(http://tomcat.apache.org/tomcat-6.0-doc/logging.html) lays these steps
out quite clearly:

1. Put a log4j.properties file in $CATALINA_HOME/lib.
2. Download Log4J (v1.2 or later) and place the log4j jar in
   $CATALINA_HOME/lib.
3. Build the commons-logging additional component using the extras.xml
   Ant build script which is part of teh Tomcat source bundle.
4. Replace $CATALINA_HOME/bin/tomcat-juli.jar with
   output/extras/tomcat-juli.jar.
5. Place output/extras/tomcat-juli-adapters.jar in $CATALINA_HOME/lib.
6. Start Tomcat

You are missing (at least) step 2.

The good news is that since your log4j.jar file is in
$CATALINA_HOME/lib, you can also use log4j in your webapp (which is
probably what you want anyway).

For more information on where Tomcat loads which classes from where, and
what the relationship of the classloaders is, see the TC Classloader
Howto: http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

- -chris

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFFyJue9CaO5/Lv0PARArAeAJ9ECUX3Ug7cp8uCIcpAFSlHqleyuACcD6Bi
a1fWzPIpIWF/l/vk5xXEA5s=
=Pl13
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to