Bom dia !
Estou tentando fazer uma aplicação simples com Myfaces, mas ganho este seguinte erro:
org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException: Resource bundle 'org.apache.myfaces.book.bundle.Messages' could not be found.
Caused by:
java.util.MissingResourceException - Can't find bundle for base name org.apache.myfaces.book.bundle.Messages, locale en_US
Minha aplicação é a seguinte:
Em lib tenho os jars: commons-beanutils.jar, commons-codec.jar, commons-collections.jar, commons-digester.jar, commons-logging.jar, myfaces-api.jar, myfaces-impl.jar, commons-discovery.jar, commons-el.jar, jstl.jar.
Em WebContent tenho:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<f:loadBundle basename="org.apache.myfaces.book.bundle.Messages"
var="message" />
<head>
<title>Your first JSF Application</title>
</head>
<body bgcolor="white">
<f:view>
<h1><h:outputText value="#{message.inputname_header}" /></h1>
<h:form id="enterInformationForm">
<h:panelGrid columns="3">
<h:outputText value="#{message.name_prompt}" />
<h:inputText id="userName" value="#{person.name}" required="true">
<f:validateLength minimum="2" maximum="30" />
</h:inputText>
<h:message style="color: red" for="userName" />
<h:outputText value="#{message.sex_prompt}" />
<h:selectOneMenu id="userSex" value="#{person.sex}">
<f:selectItem itemLabel="male" itemValue="male" />
<f:selectItem itemLabel="female" itemValue="female" />
</h:selectOneMenu>
<h:message style="color: red" for="userSex" />
<h:message style="color: red" for="userSex" />
<h:outputText value="#{message.address_prompt}" />
<h:inputTextarea id="userAddress" value="#{person.address}"
required="true"></h:inputTextarea>
<h:message style="color: red" for="userAddress" />
</h:panelGrid>
<h:commandButton id="submit" action="#{person.viewDetails}"
value="View my information" />
</h:form>
</f:view>
</body>
</html>
e
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<f:loadBundle basename="org.apache.myfaces.book.bundle.Messages" var="message"/>
<html>
<head>
<title>Your first JSF Application</title>
</head>
<body>
<f:view>
<h1><h:outputText value="#{message.result_text}"/></h1>
<h:form id="informationViewForm">
<h:panelGrid columns="2" border="1">
<h:outputText value="#{message.name_prompt}"/>
<h:outputText value="#{person.name}" />
<h:outputText value="#{message.sex_prompt}"/>
<h:outputText value="#{person.sex}" />
<h:outputText value="#{message.address_prompt}"/>
<h:outputText value="#{person.address}" />
</h:panelGrid>
<h:commandLink value="Back" action="back"></h:commandLink>
</h:form>
</f:view>
</body>
</html>
Em WEB-INF tenho:
<faces-config>
<managed-bean>
<description>Person Bean</description>
<managed-bean-name>person</managed-bean-name>
<managed-bean-class>filipe.bean.PersonBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<from-view-id>/enterInformation.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/welcome.jsp</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/welcome.jsp</from-view-id>
<navigation-case>
<from-outcome>back</from-outcome>
<to-view-id>/enterInformation.jsp</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
</faces-config>
e
<?xml version="1.0"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>MyFirstJSF</display-name>
<context-param>
<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
<param-value>server</param-value>
</context-param>
<listener>
<listener-class>
org.apache.myfaces.webapp.StartupServletContextListener</listener-class>
</listener>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>*.jsf</url-pattern>
</servlet-mapping>
</web-app>
Já tentei procurar a solução em muitos locais mas não consegui. Espero por ajuda.
Att,
Filipe Santana.