I'm using a library that has a dependency on JSF.
When I try to run my project, it show following exception massage..
java.util.MissingResourceException: Can't find bundle for base name /Bundle, locale en_US at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1427) at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1250) at java.util.ResourceBundle.getBundle(ResourceBundle.java:705)
Any ideas ?
This problem is usually happened in the Eclipse IDE environment, where it doesn't copy the “. properties” file extension by default. So, just make sure the properties file is existed in the run time “classes” folder and can be located by your web application.
Commonly used methods of ResourceBundle class public static ResourceBundle getBundle(String basename, Locale locale) returns the instance of the ResourceBundle class for the specified locale. public String getString(String key) returns the value for the corresponding key from this resource bundle.
To fix the MissingResourceException , it should be ensured that any resource required by the program exists with the correct name and at the right location. Any values attempted to be retrieved from a resource file using a key should exist with the right key.
getBundle. Gets a resource bundle using the specified base name, locale, and class loader. This method behaves the same as calling getBundle(String, Locale, ClassLoader, Control) passing a default instance of ResourceBundle. Control .
The exception is telling that a Bundle_en_US.properties
, or Bundle_en.properties
, or at least Bundle.properties
file is expected in the root of the classpath, but there is actually none.
Make sure that at least one of the mentioned files is present in the root of the classpath. Or, make sure that you provide the proper bundle name. For example, if the bundle files are actually been placed in the package com.example.i18n
, then you need to pass com.example.i18n.Bundle
as bundle name instead of Bundle
.
In case you're using Eclipse "Dynamic Web Project", the classpath root is represented by src
folder, there where all your Java packages are. In case you're using a Maven project, the classpath root for resource files is represented by src/main/resources
folder.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With