1

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.

Community
  • 1
  • 1
Esteban Rincon
  • 2,040
  • 3
  • 27
  • 44
  • try to remove `com.cleanup.` and see if it's working ??? – Yagami Light Feb 08 '17 at 09:39
  • @YagamiLight, I tried that already :/ – Esteban Rincon Feb 08 '17 at 13:41
  • 2
    I'm not familiar with Netbeans, but I see that you're using Maven. Isn't there a src/main/resources folder? You should be putting resources there in Maven projects. Perhaps it's the "Other Sources" as Netbeans calls it? See also a.o. http://stackoverflow.com/questions/13540907/maven-and-jsf-webapp-structure-where-exactly-to-put-jsf-resources – BalusC Feb 10 '17 at 13:22
  • 1
    You can always try the concept of debugging and see what is actually going on. Setting a breakpoint in the class that according to the stacktrace throws the exception should not be that difficult. Very easy to do an very educational – Kukeltje Feb 10 '17 at 14:06
  • Have you added that faces-confing in web.xml? – Gaurav Jeswani Feb 11 '17 at 09:15

2 Answers2

2

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

Jaqen H'ghar
  • 4,305
  • 2
  • 14
  • 26
1

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

Varttika
  • 11
  • 2