Search code examples
javajsfjsf-2locale

JSF Local config not working


I've configured Locale before in JSF applications, but for some reason I keep getting the following:

java.util.MissingResourceException: Can't find bundle for base name com.cleanup.bundle.messages, locale es

faces-config.xml

<application>

    <resource-bundle>
        <base-name>com.cleanup.bundle.messages</base-name>
        <var>msg</var>
    </resource-bundle>

    <locale-config> 
        <default-locale>es</default-locale>
        <supported-locale>en</supported-locale>
    </locale-config>

</application>

The .properties files:

project

For some reason I just can't make it work, please don't mark as duplicate since I've already verified with these:

  1. this
  2. and this
  3. also this
  4. etc ...

My configuration is exactly the same as I've used in the past but.. nothing works, I even tried to set the local to the default locale:

<f:view locale="#{languageBean.locale}">

With a bean like so:

@Named(value = "languageBean")
@SessionScoped
public class LanguageBean implements Serializable {

    private Locale locale;

    @PostConstruct
    public void init() {
        locale = FacesContext.getCurrentInstance().getApplication().getDefaultLocale();
    }

And for some reason getting the same MissingResourceException.

Any help is greatly appreciated, thanks.


Solution

  • Select "Files" tab instead, and put the files in the folder

    src -> main -> resources (create it if it's not there).

    Back on the projects tab, they should turn up under

    "Other sources" -> src/main/resources -> default package.

    Files tab:

    enter image description here

    Projects tab:

    enter image description here

    I'd also remove the package name (or to say, I haven't tried with that).