java.lang.ClassNotFoundException: HttpServletRequest
Caused by: java.lang.NoClassDefFoundError: HttpServletRequest
The above problem can be because the javax
library is not found.
I solved the same problem with:
Right click on the project in Eclipse → Properties
→ Java Build Path
→ Libraries
→ Add library...
→ Server Runtime
→ Apache Tomcat
add following in your pom.xml .it works for me.
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
Your web app has servlet container specific libraries like servlet-api.jar
file in its /WEB-INF/lib
. This is not right. Remove them all. The /WEB-INF/lib
should contain only the libraries specific to the Web app, not to the servlet container. The servlet container (like Tomcat) is the one who should already provide the servlet container specific libraries. If you supply libraries from an arbitrary servlet container of a different make/version, you'll run into this kind of problems, as your web app wouldn't be able to run on a servlet container of a different make/version than those libraries originated from.
This is a pretty common starter's mistake when they encounter compile-time errors, as they haven't set up their IDE project right. See also How do I import the javax.servlet API in my Eclipse project?