I'm having problem getting Spring Framework 4 to work with my existing project using Servlet 2.5. My web project actually runs fine, but my testcases are failing and it is caused by MockHttpServletRequest
, which throws this exception:-
java.lang.NoClassDefFoundError: javax/servlet/AsyncContext
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
I tried adding either dependency, but I'll get other Servlet 3.0 related exceptions:-
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>6.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mortbay.jetty</groupId>
<artifactId>servlet-api</artifactId>
<version>3.0.20090124</version>
<scope>test</scope>
</dependency>
Based on the Spring Framework website, it is said to work with Servlet 2.5. However, Spring 4's MockHttpServletRequest
seems to rely on Servlet 3.0 forward.
How do I fix this problem? Thanks.