I use Spring MVC, Tomcat 7 server.

When the site is localized, an HTTP Status 500 error - javax.servlet.ServletException occurs : javax.servlet.jsp.JspTagException: No message found under the code 'home' for locale 'en_US'. BUT I do not use Russian localization in general, only English and Ukrainian. Accordingly, there are two files, messages_en.properties and messages_ua.properties.

This error occurs only on the first page that is listed in on other pages, everything is fine, and the message change is correct.

-Servlet.xml code

<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource" id="messageSource"> <property name="basename" value="classpath:/messages"></property> <property name="defaultEncoding" value="UTF-8"></property> </bean> <bean class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor" id="localeChangeInterceptor"> <property name="paramName" value="lang"></property> </bean> <bean class="org.springframework.web.servlet.i18n.CookieLocaleResolver" id="localeResolver"> <property name="defaultLocale" value="en"></property> </bean> 

The index.jsp page displays <spring:message code="home"/> .

Inteliji, chrome, tomcat tried to clear the cache - it did not help.

Link to git with the project https://github.com/seltsamD/trouble_localization

  • one
    What is the locale of the JVM? What language does the browser request the page from? - Slava Semushin
  • JVM - uk_UA, and browsers tested different: chrome with English asks for Russian, Edge with Russian for asks for English. - seltsam
  • Most likely it will not help, but try adding <property name="fallbackToSystemLocale" value="false"></property> to the messageSource bean messageSource . I also advise you to rename messages_en.properties in messages.properties . - Slava Semushin
  • Alas, it did not help. .properies renamed and added ru_RU localization, but the error remains the same. - seltsam
  • Well then just debazhit. Do you have the opportunity to give access to the sources or create a test project in which this error would manifest? - Slava Semushin

1 answer 1

The error is related to the settings of IntelliJ IDEA. Since you used Utlimate Edition for development, I wasn’t able to launch your application on Community Edition properly. Unfortunately, your project cannot be started otherwise. I had to edit the project to make a web application out of it from a Maven point of view. After that, I was able to plug it into Tomcat, but in this configuration the error did not reproduce.

So, I advise you to convert your application into a normal web application so that it can run in any other environment. You will need this in any case if you want to run it anywhere else other than your computer.

  • Thank! By rewriting the application with annotations instead of .xml, everything worked. - seltsam