Hi Rishi,

Notice that you didn't get a ClassNotFoundException, but a NoClassDefFoundError. They are very different. The former means that it couldn't be found on the classpath where the latter means that at least one was found, but not the version it expected. This is usually caused by different versions of the class viewable by the classloader. Double check that you dont' have an old version of log4j.jar in JAVA_HOME/jre/lib/ext or something like that.

Also, how are you starting Tomcat? Is it via the scripts or via an installed service? The scripts eschew the system classpath altogether, but if you run as a service, you are at the mercy of whatever junk is on your system classpath (if you provided it to the service installer). Of course, jre/lib/ext or jre/lib/endorsed are viewed as part of the JDK so watch what you put there. It will almost always mess things up.

The easiest way to avoid collisions with various versions of log4j.jar running around is to put the jar in the WEB-INF/lib directory of your webapp. And, as Paul mentioned in his reply, put log4j.xml or log4j.properties in WEB-INF/classes to allow log4j to use default initialization without you having to intervene with an init servlet.

Let us know how things go after you do that.

Jake

At 02:48 AM 8/27/2003 +0100, you wrote:
Hi all,

I have a servlet running in Tomcat, which I have setup to do logging via
log4j. However, I get the foll. error when I try to run my app:

java.lang.NoClassDefFoundError: org/apache/log4j/Category

I have the jog4j-1.2.8.jar file in my classpath.

I have also done:
PropertyConfigurator.configure("http://localhost:8080/examples/log4j.properties";);
where log4j.properties looks like:
log4j.rootLogger=INFO, d1
log4j.appender.d1=org.apache.log4j.FileAppender
log4j.appender.d1.layout=org.apache.log4j.SimpleLayout

Can anyone give me hints as to what's wrong?

thanks!
Rishi

________________________________________________________________________
Yahoo! India Promos: Win TVs, Bikes, DVD players & more!
Go to http://in.promos.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to