aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes log4j ClassNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "log4j ClassNotFoundException" Watch "log4j ClassNotFoundException" New topic
Author

log4j ClassNotFoundException

Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Hi everybody,

i am not sure if this is the right place to ask a question about log4j ,please redirect me to thr right place if i am wrong.
i followed this link to integrate log4j with eclipse

http://snippets.dzone.com/posts/show/3248

but when i run the servlet that use the Logger ,i get this exception

SEVERE: Allocate exception for servlet testRate
java.lang.ClassNotFoundException: org.apache.log4j.Logger
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1386)
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1232)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at helper.TestRateServlet.<clinit>(TestRateServlet.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance0(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1089)
at org.apache.catalina.core.StandardWrapper.allocate(StandardWrapper.java:791)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:127)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:172)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:174)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:875)
at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:689)
at java.lang.Thread.run(Unknown Source)



any ideas??

Thanks
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Log4J needs to be deployed to the web server.
Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Thanks David,
But i am new to log4j and i don not know what do you mean by deploying log4j to the server
I am using tomcat, if you could give me more directions that would be great.

Thanks in advance
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


Add the log4j jar to your application lib path.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

It depends on how your web app/Eclipse is set up. One way would be to put it in your WEB-INF/lib directory if you have one.
Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Thanks David and Balu ,your answer solved my problem but now i am getting this warning

log4j:WARN No appenders could be found for logger (org.log).
log4j:WARN Please initialize the log4j system properly.

and i cannot see my logs
i have log4j.properties in log4j folder inside my application folder(beside src folder)

Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


i have log4j.properties in log4j folder inside my application folder(beside src folder)


log4j.properties should be in the Classpath , precisly in classes folder.
Src is for source directory , it might be confusing to differentiate in IDE. So make sure you put log4j , inside bin where classes are there.
Raghda Ismail
Greenhorn

Joined: Feb 22, 2009
Posts: 23
Thanks Balu ,
i moved log4j.properties in classes folder and it works fine now
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


you are welcome.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: log4j ClassNotFoundException