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?

user3565529
  • 1,317
  • 2
  • 14
  • 24
  • Possible duplicate of [java.util.MissingResourceException: Can't find bundle for base name javax.servlet.LocalStrings, locale es\_ES](http://stackoverflow.com/questions/31561603/java-util-missingresourceexception-cant-find-bundle-for-base-name-javax-servle) – haihui Mar 03 '16 at 10:04
  • 1
    I looked at that link, I have the same dependency in my project but even with that I am facing this issue. – user3565529 Mar 03 '16 at 10:08

1 Answers1

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>
Sam Brannen
  • 29,611
  • 5
  • 104
  • 136