| Author |
Getting exception while instantiating servlet class
|
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
Hi, am new to log4j and try to use it in one starting Testing Servlet. I created log4j.properties in WEB-INF/classes and placed the all the required jars correctly. When I try to run my servlet with this code private static Logger logger = Logger.getLogger(X.class); am getting the exception --->>> "javax.servlet.ServletException: Error instantiating servlet class X" and rootcause --->>>> "java.lang.NoClassDefFoundError: org/apache/log4j/Logger" can you please help me how to resolve it?? thanks indu
|
thanks,
indu
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
Hi Indu, It's basically saying that it can't find the log4j classes on the CLASSPATH, do you have log4j-<version>.jar somewhere on the CLASSPATH?
|
Cheers, Martijn - Blog,
Twitter, PCGen, Ikasan, My The Well-Grounded Java Developer book!,
My start-up.
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
yes, Martijn I added all the required jars in classpath... still getting the same exception.. thanks indu
|
 |
Jaikiran Pai
Marshal
Joined: Jul 20, 2005
Posts: 8145
|
|
|
This looks like a web application. How did you add that jar to the classpath?
|
[My Blog] [JavaRanch Journal]
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
thanks for all who responded to me.. It has solved... indu
|
 |
Martijn Verburg
author
Bartender
Joined: Jun 24, 2003
Posts: 3268
|
|
Hi Indu, Can you post here how you solved it? It will help others that have the same problem! Oh and well done!
|
 |
indu yeturu
Ranch Hand
Joined: Aug 27, 2008
Posts: 123
|
|
Hi Martijn, At first what your observation was correct. You advised me to check classpath properly. I added log4j(..).jar in project level WEB-INF/lib... and thought it is enough. But after adding log4j(..).jar in commons/lib under the Tomcat-home ,then it started to find that jar. My first web application with log4j is working fine now. thanks indu
|
 |
 |
|
|
subject: Getting exception while instantiating servlet class
|
|
|