I am trying to setup the Junit test with the MockMVC.
From this link - \"either must not use the Servlet API or you need to provide it on the classpath\".
I
It is a common issue. As Aniket Thakur said, the container will provide all Java servlet classes at runtime. But during the tests you need a jar to provide them.
The dependency you added to your pom is only the API : it declares everything but contains no implementation. So it will not help. Anyway, you declare it as "provided" which says to maven "don't worry, I know it will be on classpath".
You have to add a dependency that bring the implementation of all Java EE classes in test
scope. In my projects I use glassfish even if I later use tomcat as a servlet container, but I once found the dependency googling for the same problem :
org.glassfish
javax.servlet
3.0
test
It should solve your NoClassDefFoundError
problem.