Is ResourceBundle fallback resolution broken in Resin3x?

Posted by LES2 on Stack Overflow See other posts from Stack Overflow or by LES2
Published on 2010-03-03T03:45:08Z Indexed on 2010/03/19 20:01 UTC
Read the original article Hit count: 355

Filed under:
|
|
|
|

Given the following ResourceBundle properties files:

  1. messages.properties
  2. messages_en.properties
  3. messages_es.properties
  4. messages_{some locale}.properties

Note: messages.properties contains all the messages for the default locale. messages_en.properties is really empty - it's just there for correctness. messages_en.properties will fall back to messages.properties!

And given the following config params in web.xml:

<context-param> 
    <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>
    <param-value>messages</param-value>
</context-param>

<context-param>
    <param-name>javax.servlet.jsp.jstl.fmt.fallbackLocale</param-name>
    <param-value>en</param-value>
</context-param>

I would expect that if the chosen locale is 'es', and a resource is not translated in 'es', then it would fall back to 'en', and finally to 'messages.properties' (since messages_en.properties is empty).

This is how things work in Jetty. I've also tested this on WebSphere.

Resin Is the Problem

The problem is when I get to Resin (3.0.23). Fallback resolution does not work at all! In order to get an messages to display, I must do the following:

  1. Rename messages.properties to messages_en.properties (essentially, swap the contents of messages.properties and messages_en.properties)
  2. Make sure ever key in messages_en.properties is also defined in messages_{every other locale}.properties (even if the exact same).

If I don't do this, I get "???some.key???" in the JSPs.

Please help! This is perplexing.

-- LES

SOLUTION

Add following to pom.xml (if you're using maven)

...
<properties>
    <taglibs.version>1.1.2</taglibs.version>
</properties>
...

    <!--
        Resin ships with a crappy JSTL implementation that doesn't work with
        fallback locales for resource bundles correctly; we therefore include
        our own JSTL implementation in the WAR, and avoid this problem. This
        can be removed if the target container is not resin.
    -->
    <dependency>
        <groupId>taglibs</groupId>
        <artifactId>standard</artifactId>
        <version>${taglibs.version}</version>
        <scope>compile</scope>
    </dependency>

© Stack Overflow or respective owner

Related posts about resin

Related posts about jsp