pessoal, sei q tem um monte de topico falando sobre isso mas nenhum resolveu o meu problema. Eu vou postar o meu aki e ver se tem alguem disposto a me ajudar.
Essa é a página de erro, que ocorre ao clicar em um botão da tela principal:
[code]HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException: /contas/cadastroConta.jsp(37,5) ‘#{cadastroContaBean.pessoas}’ Error reading ‘pessoas’ on type br.com.financas.imperiumpecunia.visao.CadastroContaBean
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
root cause
org.apache.jasper.el.JspELException: /contas/cadastroConta.jsp(37,5) ‘#{cadastroContaBean.pessoas}’ Error reading ‘pessoas’ on type br.com.financas.imperiumpecunia.visao.CadastroContaBean
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:107)
javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:117)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
root cause
java.lang.ExceptionInInitializerError
br.com.financas.imperiumpecunia.util.HibernateUtil.(HibernateUtil.java:16)
br.com.financas.imperiumpecunia.negocio.PessoaService.listarTodas(PessoaService.java:23)
br.com.financas.imperiumpecunia.visao.CadastroContaBean.getPessoas(CadastroContaBean.java:55)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstValue.getValue(AstValue.java:123)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:117)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
root cause
org.hibernate.HibernateException: /hibernate.cfg.xml not found
org.hibernate.util.ConfigHelper.getResourceAsStream(ConfigHelper.java:170)
org.hibernate.cfg.Configuration.getConfigurationInputStream(Configuration.java:1453)
org.hibernate.cfg.Configuration.configure(Configuration.java:1475)
org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1017)
org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:64)
org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
org.hibernate.cfg.AnnotationConfiguration.configure(AnnotationConfiguration.java:1011)
br.com.financas.imperiumpecunia.util.HibernateUtil.(HibernateUtil.java:13)
br.com.financas.imperiumpecunia.negocio.PessoaService.listarTodas(PessoaService.java:23)
br.com.financas.imperiumpecunia.visao.CadastroContaBean.getPessoas(CadastroContaBean.java:55)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
java.lang.reflect.Method.invoke(Unknown Source)
javax.el.BeanELResolver.getValue(BeanELResolver.java:62)
javax.el.CompositeELResolver.getValue(CompositeELResolver.java:54)
com.sun.faces.el.FacesCompositeELResolver.getValue(FacesCompositeELResolver.java:64)
org.apache.el.parser.AstValue.getValue(AstValue.java:123)
org.apache.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:186)
org.apache.jasper.el.JspValueExpression.getValue(JspValueExpression.java:101)
javax.faces.component.UISelectItems.getValue(UISelectItems.java:130)
com.sun.faces.renderkit.RenderKitUtils.getSelectItems(RenderKitUtils.java:323)
com.sun.faces.renderkit.html_basic.MenuRenderer.getOptionNumber(MenuRenderer.java:675)
com.sun.faces.renderkit.html_basic.MenuRenderer.renderSelect(MenuRenderer.java:793)
com.sun.faces.renderkit.html_basic.MenuRenderer.encodeEnd(MenuRenderer.java:335)
javax.faces.component.UIComponentBase.encodeEnd(UIComponentBase.java:833)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:279)
com.sun.faces.renderkit.html_basic.GroupRenderer.encodeChildren(GroupRenderer.java:117)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
com.sun.faces.renderkit.html_basic.HtmlBasicRenderer.encodeRecursive(HtmlBasicRenderer.java:271)
com.sun.faces.renderkit.html_basic.GridRenderer.encodeChildren(GridRenderer.java:242)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.render.Renderer.encodeChildren(Renderer.java:137)
javax.faces.component.UIComponentBase.encodeChildren(UIComponentBase.java:809)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:886)
javax.faces.component.UIComponent.encodeAll(UIComponent.java:892)
com.sun.faces.application.ViewHandlerImpl.doRenderView(ViewHandlerImpl.java:244)
com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:175)
com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:106)
com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:251)
com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:144)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.
Apache Tomcat/6.0.29[/code]
Pelo meu entendimento, que é bem básico em JSF, ele acusa erro no cadastroConta.jsp. Eis abaixo o arquivo:
[code]<%@ page language=“java” contentType=“text/html; charset=ISO-8859-1”
pageEncoding=“ISO-8859-1”%>
<%@ taglib prefix=“f” uri=“http://java.sun.com/jsf/core”%>
<%@ taglib prefix=“h” uri=“http://java.sun.com/jsf/html”%>
<h:messages layout="table" showSummary="true" showDetail="false"
globalOnly="true" styleClass="msgErro" infoClass="msgInfo"
style="font-weight: bold" />
<h:panelGrid columns="2">
<h:outputLabel value="Código:"
rendered="#{cadastroContaBean.contaEdicao.id != null}" />
<h:panelGroup rendered="#{cadastroContaBean.contaEdicao.id != null}">
<h:inputText id="codigo" size="10"
value="#{cadastroContaBean.contaEdicao.id}" label="Código da conta"
disabled="true" />
<h:message for="codigo" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Pessoa:" />
<h:panelGroup>
<h:selectOneMenu id="pessoa"
value="#{cadastroContaBean.contaEdicao.pessoa}" label="Pessoa"
required="true">
<f:selectItems value="#{cadastroContaBean.pessoas}" />
</h:selectOneMenu>
<h:message for="pessoa" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Tipo:" />
<h:panelGroup>
<h:selectOneRadio id="tipo"
value="#{cadastroContaBean.contaEdicao.tipo}" label="Tipo da conta"
required="true">
<f:selectItems value="#{cadastroContaBean.tiposLancamentos}" />
</h:selectOneRadio>
<h:message for="tipo" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Descrição:" />
<h:panelGroup>
<h:inputText id="descricao" size="40" maxlength="150"
value="#{cadastroContaBean.contaEdicao.descricao}" required="true"
label="Descrição" />
<h:message for="descricao" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Valor:" />
<h:panelGroup>
<h:inputText id="valor" size="12" maxlength="10"
value="#{cadastroContaBean.contaEdicao.valor}" required="true"
label="Valor">
<f:convertNumber minFractionDigits="2" />
</h:inputText>
<h:message for="valor" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Data vencimento:" />
<h:panelGroup>
<h:inputText id="dataVencimento" size="12" maxlength="10"
value="#{cadastroContaBean.contaEdicao.dataVencimento}"
required="true" label="Data vencimento">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:inputText>
<h:message for="dataVencimento" showSummary="true"
showDetail="false" styleClass="msgErro" />
</h:panelGroup>
<h:outputLabel value="Data baixa:" />
<h:panelGroup>
<h:inputText id="dataBaixa" size="12" maxlength="10"
value="#{cadastroContaBean.contaEdicao.dataBaixa}"
label="Data baixa">
<f:convertDateTime pattern="dd/MM/yyyy" />
</h:inputText>
<h:message for="dataBaixa" showSummary="true" showDetail="false"
styleClass="msgErro" />
</h:panelGroup>
<h:panelGroup />
<h:panelGroup>
<h:commandButton value="Salvar"
actionListener="#{cadastroContaBean.salvar}" styleClass="botao" />
<h:commandButton value="Cancelar" action="menu" immediate="true"
styleClass="botao" />
</h:panelGroup>
</h:panelGrid>
</h:form>
</f:view>
[/code]O servidor critica também a classe CadastroContaBean, que segundo ele, o erro está no atributo “pessoas”. Logo, afetando também seu respectivo JSP. Eis a classe abaixo:
[code]package br.com.financas.imperiumpecunia.visao;
import java.util.ArrayList;
import java.util.List;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import br.com.financas.imperiumpecunia.dominio.Conta;
import br.com.financas.imperiumpecunia.dominio.Pessoa;
import br.com.financas.imperiumpecunia.dominio.TipoConta;
import br.com.financas.imperiumpecunia.negocio.ContaService;
import br.com.financas.imperiumpecunia.negocio.PessoaService;
import br.com.financas.imperiumpecunia.negocio.RegraNegocioException;
public class CadastroContaBean {
private Conta contaEdicao;
private List<SelectItem> tiposContas;
private List<SelectItem> pessoas;
public String inicializar() {
this.contaEdicao = new Conta();
this.tiposContas = null;
this.pessoas = null;
return "cadastroConta";
}
public void salvar(ActionEvent event) {
FacesContext context = FacesContext.getCurrentInstance();
try {
new ContaService().salvar(this.contaEdicao);
this.contaEdicao = new Conta();
FacesMessage msg = new FacesMessage("Conta salva com sucesso!");
msg.setSeverity(FacesMessage.SEVERITY_INFO);
context.addMessage(null, msg);
} catch (RegraNegocioException e) {
context.addMessage(null,
new FacesMessage(FacesMessage.SEVERITY_ERROR, e
.getMessage(), e.getMessage()));
} catch (Exception e) {
e.printStackTrace();
FacesMessage msg = new FacesMessage(
"Erro inesperado ao salvar conta!");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
context.addMessage(null, msg);
}
}
public List<SelectItem> getPessoas() {
if (this.pessoas == null) {
this.pessoas = new ArrayList<SelectItem>();
List<Pessoa> pessoas = new PessoaService().listarTodas();
this.pessoas.add(new SelectItem(null, "Selecione"));
for (Pessoa pessoa : pessoas) {
this.pessoas.add(new SelectItem(pessoa, pessoa.getNome()));
}
}
return this.pessoas;
}
public List<SelectItem> getTiposLancamentos() {
if (this.tiposContas == null) {
this.tiposContas = new ArrayList<SelectItem>();
for (TipoConta tipo : TipoConta.values()) {
this.tiposContas.add(new SelectItem(tipo, tipo.toString()));
}
}
return tiposContas;
}
public Conta getContaEdicao() {
return contaEdicao;
}
public void setContaEdicao(Conta contaEdicao) {
this.contaEdicao = contaEdicao;
}
}[/code]
Bom… e como sempre acontece erro nas configurações, segue abaixo também o faces-config.xml e o web.xml:
FACES-CONFIG.XML
[code]<?xml version="1.0" encoding="UTF-8"?>
<application>
<message-bundle>br.com.financas.imperiumpecunia.recursos.messages</message-bundle>
</application>
<managed-bean>
<managed-bean-name>cadastroContaBean</managed-bean-name>
<managed-bean-class>
br.com.financas.imperiumpecunia.visao.CadastroContaBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<managed-bean>
<managed-bean-name>consultaContaBean</managed-bean-name>
<managed-bean-class>
br.com.financas.imperiumpecunia.visao.ConsultaContaBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
<navigation-rule>
<navigation-case>
<from-outcome>cadastroConta</from-outcome>
<to-view-id>/contas/cadastroConta.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-outcome>consultaConta</from-outcome>
<to-view-id>/contas/consultaConta.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<navigation-case>
<from-outcome>menu</from-outcome>
<to-view-id>/menu.jsp</to-view-id>
<redirect />
</navigation-case>
</navigation-rule>
<converter>
<converter-for-class>java.lang.Enum</converter-for-class>
<converter-class>
br.com.financas.imperiumpecunia.conversores.EnumConverter</converter-class>
</converter>
<converter>
<converter-for-class>br.com.financas.imperiumpecunia.dominio.Pessoa</converter-for-class>
<converter-class>
br.com.financas.imperiumpecunia.conversores.PessoaConverter</converter-class>
</converter>
[/code]
WEB.XML
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>imperiumpecunia</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
<welcome-file>default.jsp</welcome-file>
</welcome-file-list>
<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>/faces/*</url-pattern>
</servlet-mapping>
</web-app>
Uufaa… rsrs… É galera…ta meio ruim, nao sei onde ta o erro que tanto o servidor reclama: “pessoas”.
Quem se habilita a me ajudar?
Agradeço a todos.