Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6129033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:41:42+00:00 2026-05-23T16:41:42+00:00

I am stuck, probably missed something in docs or made some small mistake. Spring

  • 0

I am stuck, probably missed something in docs or made some small mistake.

Spring Security 3.0.5 was integrated in my Spring MVC 3.0.5 app. AcceptHeaderLocaleResolver is used for Locale detection and localisation works ok except for Security error messages.

I copied messages.properties from spring security package and renamed and added to existing “messageSource” bean (ResourceBundleMessageSource) with value list.

As said earlier all texts and messages are localised correctly, except Security seams to use hardcoded English messages.

Any ideas how to solve this?

UPDATE:
My xy-servlet.xml contains:

...
<mvc:resources mapping="/resources/**" location="/resources/" />
...
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>defaultMessages</value>
            <value>securityMessages</value>
        </list>
    </property>
</bean>

and files

  • defaultMessages.properties
  • defaultMessages_en.properties
  • defaultMessages_de.properties
  • defaultMessages_sl.properties

and

  • securityMessages.properties
  • securityMessages_en.properties
  • securityMessages_de.properties
  • securityMessages_sl.properties

but defaultMessages work ok. securityMessages does not. I made small changes in all securityMessages files, but they are ignored and the hardcoded english messages are displayed.

UPDATE v2:
My dispatcher-servlet.xml:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd  
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
    http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd">

<context:component-scan base-package="com.example.sampleapp1" />
<context:annotation-config />

<mvc:annotation-driven/>

<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources/ directory -->
<mvc:resources mapping="/resources/**" location="/resources/" />

<bean id="viewResolver"
    class="org.springframework.web.servlet.view.InternalResourceViewResolver"
    p:prefix="/WEB-INF/views/" p:suffix=".jsp" />

<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
    <property name="basenames">
        <list>
            <value>defaultMessages</value>
            <value>securityMessages</value>
            <value>org/springframework/security/messages_de</value>
        </list>
    </property>
</bean> 

<!-- Persistence -->
<bean id="myPMF" class="org.springframework.orm.jdo.LocalPersistenceManagerFactoryBean">
    <property name="persistenceManagerFactoryName" value="transactions-optional"/>
</bean>     

<!-- Form Validator -->

</beans>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:41:43+00:00Added an answer on May 23, 2026 at 4:41 pm

    Finally, solution!

    Bean for security messages apparently must me declared in applicationContext-security.xml
    and not in app context xml config… I did not find this anywhere in manual!

    In my case correct solution is bean in applicationContext-security.xml:

        <b:bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
            <b:property name="basenames">
                <b:value>secMessages</b:value>
            </b:property>
        </b:bean>
    

    Thanks to @bluefoot and @jtoberon for some ideas.

    UPDATE:
    To work this properly web.xml must contain localizationFilter before springSecurityFilterChain, my web.xml is:

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
    
    <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/applicationContext-security.xml</param-value>
    </context-param>
    
    <!-- i18n -->
    <filter>
        <filter-name>localizationFilter</filter-name>
        <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
    </filter>
    
    <filter>
        <filter-name>springSecurityFilterChain</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    
    <!-- i18n -->
    <filter-mapping>
        <filter-name>localizationFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>
    
    <filter-mapping> 
      <filter-name>springSecurityFilterChain</filter-name> 
      <url-pattern>/*</url-pattern>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
        <dispatcher>INCLUDE</dispatcher>
        <dispatcher>ERROR</dispatcher>
    </filter-mapping> 
    
    
    <!-- Creates the Spring Container shared by all Servlets and Filters -->
    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
    
    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>
    
    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>
    
    </web-app>
    

    Check lines after i18n comments.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Noob here getting stuck and probably doing something stupid and would appreciate some guidance.
I have a question probably lame but it made me stuck I have the
Probably simple question and I'm just missing something, but I'm stuck out of ideas.
I am new to js and a bit stuck (with something that is probably
I'm stuck with something which is probably quite simple to resolve but don't have
I am stuck in something that probably for you might think is simple! In
This is probably easy but I am getting stuck: when I build a solution
This is probably a simple one to answer, but I'm stuck, so here goes.
I'm a bit stuck on this. Basically I want to do something like the
I'm stuck on a fix to a legacy Visual C++ 6 app. In the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.