3

I am writing test for a servlet filter using spring MockHttpServletResponse and request. I am getting the following error while creating MockHttpServletResponse object.

Caused by: java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale en_US

I tried couple of things suggested on stackoverflow like adding javax.servlet-api to pom but even with that its not working. I tried adding tomcat server api in pom, but that is also not working.

My pom file just contains servlet api, jmockit and spring-test dependencies. And I dont have any message.properties or any other resource in classpath.

Is there any other dependency that I need to add here?

2

1 Answer 1

1

You need the appropriate version of javax.servlet:javax.servlet-api in the test classpath.

For Maven, you will need something similar to the following.

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>test</scope>
</dependency>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.