Reputation: 641
I keep getting this error: java.lang.ClassNotFoundException: javax.servlet.Servlet when I attempt to run my servlet in eclipse.
I am using the web version of eclipse in conjunction with Tomcat. I have servlet-api.jar in the library, as well as javaee-6.0.jar imported (though I believe I am using java 7, this was the most recent version of this I could find)
So why do I keep getting this error? I've scoured the web and the solution has always been servlet-api.jar, but I have this file in the library to no benefit.
Thank you in advance!
Upvotes: 0
Views: 6796
Reputation: 22382
You correctly have added servlet.jar and javaee.jar. The error you specified is typically happens when one of those two files are missing. However, since you have those files, I recommend doing the following:
Upvotes: 0
Reputation: 823
Even though you have your servlet-api.jar you most probably dont need to bundle it with your war. Generally tomcat uses it own servlet-api, which is located ./common/lib/servlet-api.jar.
Most probably you are missing this, which causes the ClassNotFoundException
Upvotes: 1
Reputation: 2414
Is that error happing during the compilation or during the run?
Did you configure Eclipse to point to the Tomcat server? In order to run a web server in eclipse using tomcat, you need to tell eclipse about tomcat first. Here is where you ca find the instruction. http://www.coreservlets.com/Apache-Tomcat-Tutorial/tomcat-7-with-eclipse.html
Upvotes: 1