views:

45

answers:

2

I am working on a J2SE application (think kiosk-style app) that makes heavy use of resource bundles and i18n. This includes not just translations but also formatting and other i18n concerns. We have custom logic in place to homogenize the resource loading, but it is fairly straightforward. The issue I have is the MissingResourceException. Even if I bypass the custom logic in place in the application and call directly into the ResourceBundle class to load this specific bundle, Java is not able to load it for a specific locale. Here is the root exception with stack trace:

Caused by: java.util.MissingResourceException: Can't find bundle for base name version1/FormatResource, locale en_GB
 at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:836)
 at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:726)
 at java.util.ResourceBundle.getBundle(ResourceBundle.java:576)

The resource bundle is in a directory "version1" placed in a class folder in Eclipse which is at the top of my class path. This folder contains other resource bundles which are loaded fine using the same resource bundle loading logic, as well as numerous XML configs which also load fine when loaded using the system class loader. The relevant files for the resource bundle are:

FormatResource_cs_CZ.properties
FormatResource_en_GB.properties
FormatResource_fr_BE.properties
FormatResource_fr_FR.properties
FormatResource_hu_HU.properties
FormatResource_nl_BE.properties
FormatResource_nl_NL.properties
FormatResource_pl_PL.properties
FormatResource_sk_SK.properties

When my application starts up in the Polish locale, everything is fine. If I log in as a user with the Polish locale, everything is fine. If I log in as a British user, the application attempts to load all the en_GB bundles (translations, formatters, etc) and fails on this bundle. It cannot find FormatResource_en_GB.properties, which is clearly in the class path: the above file list is a copy and paste from the command line.

One final issue that I find interesting is that if I define FormatResource_en_US.properties in the version1 directory, then even the FormatResource_pl_PL.properties file fails to load and the application will not even start.

Anyone have any ideas?

A: 

I would try to test for file & operating system issues like permissions.

Rename your FormatResource_en_GB.properties so it's out of the way and copy one of the working FormatResource files in its place.

Jonathon
A: 

I find it interesting that you mention when you put the US at the top of the list that it loads that one and not any other (similar for when Polish was at the top). Are you switching the locale when you look up the next resource bundle? or is it holding onto the default set by when the program first fired up?

Another thought is with class loaders....whenever I have encountered properties files not being located properly (even though they are where I expect them), I've ended up having to look at how the classloader is loading things. Usually it has been different from what I suspected (like a duplicate file someplace else, or multiple classloaders conflicting with each other).

Just two thoughts to try.

Chris Aldrich