0
votes

I am doing a simple JSF based project (please refer to this image to check out the project structure) but I can't figure out why the faces-config can not reach to the Messages.

Here is the piece of code on the "faces-config.xml" that references the "Messages.properties" file:

    <application>
      <message-bundle>br.com.teste.primeiraaplicacaojsf.web.i18n.Messages</message-bundle>
      <locale-config>
        <default-locale>pt_BR</default-locale>
      </locale-config>
    </application>

Here is the error message generated on the browser:

HTTP Status 500 - Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR

type Exception report

message Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR

description The server encountered an internal error that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:671)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
root cause

java.util.MissingResourceException: Can't find bundle for base name br.com.teste.primeiraaplicacaojsf.web.i18n.Messages, locale pt_BR
    java.util.ResourceBundle.throwMissingResourceException(ResourceBundle.java:1564)
    java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:1387)
    java.util.ResourceBundle.getBundle(ResourceBundle.java:1082)
    javax.faces.component.MessageFactory.getMessage(MessageFactory.java:161)
    javax.faces.component.MessageFactory.getMessage(MessageFactory.java:251)
    javax.faces.component.UIInput.validateValue(UIInput.java:1149)
    javax.faces.component.UIInput.validate(UIInput.java:982)
    javax.faces.component.UIInput.executeValidate(UIInput.java:1248)
    javax.faces.component.UIInput.processValidators(UIInput.java:712)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    javax.faces.component.UIForm.processValidators(UIForm.java:253)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    javax.faces.component.UIComponentBase.processValidators(UIComponentBase.java:1261)
    javax.faces.component.UIViewRoot.processValidators(UIViewRoot.java:1195)
    com.sun.faces.lifecycle.ProcessValidationsPhase.execute(ProcessValidationsPhase.java:76)
    com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
    com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:198)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:658)
    org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:51)
1
Rename your Messages.properties to Messages_pt_BR.properties, build, deploy and see if it will work, please.Bonifacio
@Bonifacio the error persists. Exactly the same.Bernardo Araujo
@Kukeltje It is in the right location within the structure, but I don't know how to check if it remains in that location after the deploy.Bernardo Araujo
@Kukeltje I double checked it, the file is in the mentioned path inside structure, as shown in the image that I've linked.Bernardo Araujo
Let your build system produce a WAR file. That represents the deployment. Now inspect that WAR file with a ZIP tool. Is the bundle file at the right location in there? (in its package structure in /WEB-INF/classes)BalusC

1 Answers

1
votes

For some reason IntelliJ project explorer was showing the the path of the "Messages.properties" file as if it was a sequence of folders while behind the curtains it was creating just one folder with the whole path as it's name. The problem was fixed by remaking the folder structure inside the resources folder (the files remain exactly the same).