This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Svelte and Sapper in Action and have Mark Volkmann on-line!
See this thread for details.
Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Warnings with message resource

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

 
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.
 
Don't play dumb with me! But you can try this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic