StackoverflowExcepton in Spring message i18n ReloadableResourceBundleMessageSource

Viewed 1348

I am enabling message i18n in my Spring web app. For this, I have below code in my servlet.xml

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:messages/message"/>
        <property name="defaultEncoding" value="UTF-8"/>
    </bean>

After adding above code, as soon as I hit my application in browser, I get below exception log:

SEVERE: Servlet.service() for servlet [default] in context with path [/ERP-Web] threw exception [Filter execution threw an exception] with root cause
java.lang.StackOverflowError
    at org.springframework.context.support.ReloadableResourceBundleMessageSource.getMergedProperties(ReloadableResourceBundleMessageSource.java:235)
    at org.springframework.context.support.ReloadableResourceBundleMessageSource.resolveCodeWithoutArguments(ReloadableResourceBundleMessageSource.java:176)
    at org.springframework.context.support.AbstractMessageSource.getMessageInternal(AbstractMessageSource.java:209)
    at org.springframework.context.support.AbstractMessageSource.getMessageFromParent(AbstractMessageSource.java:257)

where last 2 lines were repeated 100s of times and gives me StackoverflowException.

Exactly same exception is coming when I am using ResourceBundleMessageSource class.

My spring version is 4.3.6.RELEASE.

Below is content of my properties file

action.add.success = New {0} added successfully.
action.add.failure = Some error occurred in adding new {0}. Please try again later or contact administrator.

Sample project is on GitHub

5 Answers
Related