Esteban Rincon
Esteban Rincon

Reputation: 2110

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.

Upvotes: 1

Views: 876

Answers (2)

Jaqen H&#39;ghar
Jaqen H&#39;ghar

Reputation: 4345

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).

Upvotes: 2

Varttika
Varttika

Reputation: 11

Have you checked your war file. It can be that the maven build is not putting your properties file at the desired location as it picks up the properties from resources folder, so try putting the package structure in resources folder and build again .The maven folder structure is src ---main |-java |-resources |- webapp

Upvotes: 1

Related Questions