Affects: Spring Framework 5.3.4

After upgrading spring to 5.3.4 the constructor of MockHttpServletRequest throws java.lang.NoClassDefFoundError: javax/servlet/http/HttpServletMapping. The project uses older servlet api 3.1 because the tomcat 8.5.x is still used in production.

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>

When the version of servlet api is changed to 4.0.0 or above, the exception is of course gone.

In [1] is mentioned that the older API should be sufficient for spring framework 5.x.

The Java EE 7 API level is required in Spring's corresponding modules now, with runtime support for the EE 8 level

[1] https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-5.x

Comment From: bclozel

Closing as a duplicate of #26555

Comment From: sbrannen

Please note that the hard dependency on Servlet 4 in spring-test will be reverted in Spring Framework 5.3.5.

For details, see https://github.com/spring-projects/spring-framework/issues/26555#issuecomment-781992923.

Comment From: jirkait

Thank you for info. This is more cleaner than the change of version suggested in #26555. I am not in favour of running tests with another version (especially higher) than the version in production because new signatures can be easily used in main code and that mistake is not covered by test.