Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: JspTagException: No message found under code 'title' for locale 'en_US'

  1. #11
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    Well, of course it worked, but when the users browser is set to use yet another locale, the error will most likely reappear again. The problem here is that the default language isn't kicking in.

    You set default language with a property to the CookieLocaleResolver with deaultLocale key and a language value :
    Code:
    <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
    	<property name="defaultLocale" value="en"/>
    </bean>
    Last edited by MiB; Oct 17th, 2011 at 06:06 AM.

  2. #12
    Join Date
    Oct 2008
    Location
    Warsaw, Poland
    Posts
    124

    Default

    Why the messages_en_US.propertries file is required in this case? Should it be the messages.properties file that is picked in case of absence of messages_X.propertries files?

  3. #13
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    I have "messages_en.properties" and I suppose that if you have internationalization in your project the framework shouldn't default a language by itself, and it's reasonable that the user should explicitly tell which language to default to. In this case Spring Roo could set or encourage the user to set a default language.

    For a newbie this is a bewildering error to encounter. For someone developing on an English system it's imagineable they could go all the way to the web before they realize that users with other locale settings in their browser don't get a default language.

    I'd assume this is also a result of the language set by Roo in the web page templates.

  4. #14
    Join Date
    Aug 2010
    Location
    Goteborg, Sweden
    Posts
    434

    Default

    Well, the scenario described happened in a real project and googlebot triggered a 500 internal server error on visiting the site in question as it assumed us-english language (en_us) until I made sure to give the page templates html element a lang attribute with the proper language of the page.

    I think this is a weakness of Spring MVC and that locale settings should be set in one place only and should also change the lang attribute of the full page. It's too obscure now.

    One simple way to detect this kind of error is to set the first language in your developer browser to something you're not likely to ever support. I went with albanian. If your page works properly the default language will still kick in, but if it doesn't it may give an error.
    Last edited by MiB; Dec 7th, 2011 at 06:46 AM.

  5. #15

    Default

    Sorry to revive an old thread, but I am having this exact same error... with a twist.

    Everything works just fine when using JDK 6, but fails when using JDK 7.

    I've tried all reasonable variations of the basename property to no avail.

  6. #16

    Default

    The smoking gun appears to be this log entry:


    13:08:21,046 DEBUG @main [org.springframework.beans.factory.support.DefaultL istableBeanFactory] Finished creating instance of bean 'messageSource'
    13:08:21,046 DEBUG @main [org.springframework.web.context.support.XmlWebAppl icationContext] Using MessageSource [org.springframework.context.support.ResourceBundle MessageSource: basenames=[messages]]

    The XmlWebApplicationContext is seemingly creating its own bogus MessageSource rather than using the one (whose id is 'messageSource') defined in the application context.

    WTF?

  7. #17

    Default

    Never mind, Java 7 was a red herring. A "hidden" context file was creating a second messageSource. For unknown reasons, the right one was preferred with Java 6, the wrong one with Java 7.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •