Skip to content

MockHttpServletRequest needs servlet api 4.0 after upgrade from 5.3.3 to 5.3.4 #26566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jirkait opened this issue Feb 18, 2021 · 3 comments
Closed
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue

Comments

@jirkait
Copy link

jirkait commented Feb 18, 2021

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

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 18, 2021
@bclozel
Copy link
Member

bclozel commented Feb 18, 2021

Closing as a duplicate of #26555

@bclozel bclozel added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Feb 18, 2021
@bclozel bclozel closed this as completed Feb 18, 2021
@sbrannen sbrannen added the in: test Issues in the test module label Feb 18, 2021
@sbrannen
Copy link
Member

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

For details, see #26555 (comment).

@jirkait
Copy link
Author

jirkait commented Feb 19, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: test Issues in the test module status: duplicate A duplicate of another issue
Projects
None yet
Development

No branches or pull requests

4 participants