| Author |
Warnings with message resource
|
Mukhi Vla
Ranch Hand
Joined: Apr 22, 2010
Posts: 50
|
|
I used message resource properties file in my project, which is in spring framework. My properties file name is 'message_us.properties'
I am getting the following WARNING:
ResourceBundle [message] not found for MessageSource: Can't find bundle for base name message, locale en_US
this is hapenning when my form has with error validation messages set. it is hapenning with SimpleFormcontroller forms.
In application context i have the following bean defined for message resources.
i also have one more problem... when i am trying to display message keys in my jsp page, it is getting back with '???msg.key???'
Can anyone help me with this ?
Thanks
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
ResourceBundles expect language codes to be lowercase and country codes to be uppercase in the property file name. So the filename should be 'message_US.properties' or 'message_en_US.properties'. The JavaDocs for ResourceBundle.getBundle() JavaDocs show what order different combinations will be loaded in. The JavaDocs for Locale links lists of valid language and country codes.
|
-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
|
 |
Mukhi Vla
Ranch Hand
Joined: Apr 22, 2010
Posts: 50
|
|
Thanks. It is working fine when I changed my properties file name from 'msgbundle_us.properties' to 'msgbundle_en_US'.I have another project that uses canadian english. So i have the properies file name as 'msgbundle_en_CA'. I am getting same WARNING 'ResourceBundle [msgbundle] not found for MessageSource: Can't find bundle for base name message, locale en_US'.
How can i get rid of this message here? I may not have en_US properties file in my project. My project is in Spring framework.
Thanks.
|
 |
Nathan Pruett
Bartender
Joined: Oct 18, 2000
Posts: 4121
|
|
Spring MVC uses the 'accept-language' header in the HTTP request to determine the user's current locale. Here's a link to the Spring Reference Documentation about default localization and how to change it. When you get the
WARNING ' ResourceBundle [msgbundle] not found for MessageSource: Can't find bundle for base name message, locale en_US'.
Are you changing anything in your browser / OS to change the 'accept-language' in the request? If not, your default may be en_US, which is what is causing this.
|
 |
Mukhi Vla
Ranch Hand
Joined: Apr 22, 2010
Posts: 50
|
|
Thanks. Where can i set this. I want to set it at application level. is there any whay i can set it in applicationContext.xml or web.xml file?
|
 |
Mukhi Vla
Ranch Hand
Joined: Apr 22, 2010
Posts: 50
|
|
I solved this by adding the following in applicationContext.xml
|
 |
gopal krishnan
Greenhorn
Joined: Dec 17, 2007
Posts: 18
|
|
i got the problem being resolved..
following are the step's i did it..
1) in the springapp-context.xml (dispacher ), i add the below
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
2) second, i placed the messages.properties file inside the /WEB-INF/classes. make sure that after clean and deploy the file stills exits.
|
 |
 |
|
|
subject: Warnings with message resource
|
|
|