Skip to content
Advertisement

Java could not find XML resource bundle

JavaScript

error:

JavaScript

If they are *.properties, no problems.

How to load XML resource bundles?

Advertisement

Answer

By default, Java SE ResourceBundle.getBundle(...) only understands loading of resource bundles implemented as Java classes or “.properties” files.

If you want to load a ResourceBundle from an XML file, you need to provide a custom ResourceBundle.Control implementation that implements the resource search and loading strategies.

There is an example in the ResourceBundle.Control javadocs; look for “Example 2”.


I briefly searched for a 3rd-party implementation of an XML ResourceBundle provider, but I couldn’t find anything generic.

(Asking recommendations is off-topic anyway.)

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement