views:

396

answers:

2

I have placed translation file app_fi.properties in folder /WEB-INF/i18n/, but I get following error message. What could be wrong here?

java.util.MissingResourceException: Can't find bundle for base name WEB-INF.i18n.app, locale fi_FI  java.util.ResourceBundle.throwMissingResourceException(Unknown Source)  java.util.ResourceBundle.getBundleImpl(Unknown Source)
    java.util.ResourceBundle.getBundle(Unknown Source)  
+1  A: 

You have to put app_*.properties in /WEB-INF/classes (or somewhere in the classpath) and load it as it were a class.

By example:

/WEB-INF/classes/i18n/pack2/app_fi.properties

is loaded with

ResourceBundle.getBundle("i18n.pack2.app", ...)
helios
If you pack some resource bundle properties in a jar, then the path inside the jar is the package. But in your concrete example do as I said: /WEB-INF/classes/the/path/you/want/app_fi.properties and load vía ResourceBundle.getBundle("the.path.you.want.app");
helios
+1  A: 

Did you add the WEB-INF/i18n folder to the containers' classpath?

rsp
He's trying to load "WEB-INF.i18n.app" resource bundle wich is misnamed (WEB-INF is part of the structure of the web application file). He doesn't need to add nothing to a classpath (cause it's a web app). And adding that to the classpath (if he could do it) isn't resolving the issue (because of the name he's requiring).
helios
@helios, I was responding to what the OP tried to achieve, place the resource in WEB-INF/i18n and load it as resource bundle. Placing it in WEB-INF/classes is a workaround, creating a resource .jar and put that in WEB-INF/lib is a better solution if you're looking at an alterniative to the i18n folder stated in the question.
rsp
Uh, ok :). Anyway if (s)he adds that dir to the classpath, needs to load it vía getBundle("app") so classpath + basename results in the path of the file where it is now.
helios
It doesn't let me unvote. Sorry. :(
helios