• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Warnings with message resource

 
Mukhi Vla
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Mukhi Vla
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I solved this by adding the following in applicationContext.xml

 
gopal krishnan
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic