I've tried this mapping and JSF just wouldn't find it.
<application>
<resource-bundle>
<base-name>/WEB-INF/i18/messages</base-name>
<var>msg</var>
</resource-bundle>
</application>
All examples I have seen put messages.properties in the Java Source folder. Some use a package name, some don't - which is pretty much still like using a blank package name. Is JSF forcing us to store resource bundles under Java Source?
This is not specific to JSF. This is specific to the
ResourceBundle
API. Bundles are by specification loaded via caller's class loader with a fully qualified base name. From the javadoc (emphasis mine):Under the covers, it is using
ClassLoader#getResourceAsStream()
to obtain anInputStream
of the classpath resource.The
/WEB-INF
folder is not part of the classpath. It's part of the web content. Web content resources are programmatically only available viaServletContext#getResourceAsStream()
and inherently in JSF viaExternalContext#getResourceAsStream()
. You can of course homegrow a customResourceBundle.Control
which loads the resource as a web content resource, but it is really not recommended to do things differently from the standard without any valid technical reason.Just put those resources in the classpath the usual way. There's no point putting them in web content.