Pregunta

I am trying to read a properties file using a resource bundle class in java, but it is giving me a exception saying that

java.util.MissingResourceException: Can't find bundle for base name jira, locale en_US

This is how i am coding in java

ResourceBundle labels = ResourceBundle.getBundle("jira");

This is my project structure enter image description here

What is that missing? I have read through the documentation and it says that no need to give any absolute path as the Resource bundle handles that.

¿Fue útil?

Solución

ResourceBundles are read from the classpath. WEB-INF/conf is not on the classpath for web applications. Try placing the property file in WEB-INF/classes.

From the above image it appears you are using Maven to build the project. In that case the property file can be moved into src/main/resources folder to be copied into classes during the Maven build.

Otros consejos

The problem is the name of your bundle file. File name should begins with the base name LabelsBundle and ends with the .properties suffix. Since you are trying to load file intended for your default Locale, the base name is followed by the language code (en_US).

jire_en_US.properties

should be the file name of your bundle file instead of just

jira.properties

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top