I am trying to hook up a messageSource in spring to use for my application. Its not working, gives this error:
org.springframework.context.NoSuchMessageException: No message found under code 'validation_required' for locale 'en'.
my applicationContext.xml contains this def for messageSource:
<bean id="messageSource"
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>classpath:messages</value>
</list>
</property>
</bean>
my messages properties file lives in:
/WEB-INF/classes/messages/messages_en_US.properties
Finally, the call i made that generates the error is:
String message = messageSource.getMessage("validation_required", null, Locale.ENGLISH);
Can anyone help me at this hour?
It seems like your path is not correct. since you have your bundle under /WEB-INF/classes/messages/messages_en_US.properties, your basename setting should look like: classpath:messages/messages (basename in this case means path and properties file prefix).
The problem is with the way you have defined the resource bundle and the locale you are specifying (They doesn't match with the resource bundle's search order. Either rename your bundle to "messages_en.properties" or invoke the "getMessage(...)" with new Locale("en","US"). I prefer the first option.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With