Olá pessoal, estou desenvolvendo um sistema web usando o Eclipse, com Java, Hibernate. É um sistema de cadastro e consultas, que ainda está na fase inicial. Quando eu tento acessar uma das jsp’s de cadastro, me retorna o seguinte erro:
[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: javax.servlet.ServletException: javax.faces.el.EvaluationException: javax.el.ELException: Error reading ‘orgaosGestores’ on type br.gov.rr.setrabes.handler.OrgaoGestorHandler
br.gov.rr.setrabes.util.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:26)
root cause
javax.servlet.ServletException: javax.faces.el.EvaluationException: javax.el.ELException: Error reading ‘orgaosGestores’ on type br.gov.rr.setrabes.handler.OrgaoGestorHandler
javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
org.ajax4jsf.webapp.BaseXMLFilter.doXmlFilter(BaseXMLFilter.java:141)
org.ajax4jsf.webapp.BaseFilter.doFilter(BaseFilter.java:281)
br.gov.rr.setrabes.util.HibernateSessionFilter.doFilter(HibernateSessionFilter.java:23)
[/code]
Já conferi o face-config.xml, já olhei a conexao com o banco, revisei as classes e as regras, os jsp’s correspondentes a esse erro e nada…
Alguém pode me ajudar?? Segue abaixo as classes e o jsp.
Valeu.
[code]@Entity
public class OrgaoGestor {
@Id
@GeneratedValue
private Long cod_orgaogestor;
private Long estados_cod_estados;
private Long municipiosrr_cod_municipiosrr;
private Long nivelgestao_cod_nivelgestao;
private String nome;
private String endereco;
private String endereco_complemento;
private String fone;
private String fax;
private String email;
public Long getCod_orgaogestor() {
return cod_orgaogestor;
}
public void setCod_orgaogestor(Long cod_orgaogestor) {
this.cod_orgaogestor = cod_orgaogestor;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getEndereco() {
return endereco;
}
public void setEndereco(String endereco) {
this.endereco = endereco;
}
public String getEndereco_complemento() {
return endereco_complemento;
}
public void setEndereco_complemento(String endereco_complemento) {
this.endereco_complemento = endereco_complemento;
}
public Long getEstados_cod_estados() {
return estados_cod_estados;
}
public void setEstados_cod_estados(Long estados_cod_estados) {
this.estados_cod_estados = estados_cod_estados;
}
public String getFax() {
return fax;
}
public void setFax(String fax) {
this.fax = fax;
}
public String getFone() {
return fone;
}
public void setFone(String fone) {
this.fone = fone;
}
public Long getMunicipiosrr_cod_municipiosrr() {
return municipiosrr_cod_municipiosrr;
}
public void setMunicipiosrr_cod_municipiosrr(
Long municipiosrr_cod_municipiosrr) {
this.municipiosrr_cod_municipiosrr = municipiosrr_cod_municipiosrr;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
public Long getNivelgestao_cod_nivelgestao() {
return nivelgestao_cod_nivelgestao;
}
public void setNivelgestao_cod_nivelgestao(Long nivelgestao_cod_nivelgestao) {
this.nivelgestao_cod_nivelgestao = nivelgestao_cod_nivelgestao;
}
}[/code]
[code]package br.gov.rr.setrabes.handler;
import java.util.ArrayList;
import java.util.List;
import javax.el.ELContext;
import javax.el.ELResolver;
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.component.UIParameter;
import javax.faces.component.html.HtmlSelectOneMenu;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.faces.model.SelectItem;
import javax.faces.validator.ValidatorException;
import org.hibernate.Session;
import br.gov.rr.setrabes.dao.Dao;
import br.gov.rr.setrabes.estrutura.Estados;
import br.gov.rr.setrabes.estrutura.MunicipiosRR;
import br.gov.rr.setrabes.estrutura.NivelGestao;
import br.gov.rr.setrabes.estrutura.OrgaoGestor;
import br.gov.rr.setrabes.util.HibernateUtil;
public class OrgaoGestorHandler {
private OrgaoGestor orgaogestor = new OrgaoGestor();
// select para estados
private HtmlSelectOneMenu estadosSelecionado;
public HtmlSelectOneMenu getestadosSelecionado() {
return estadosSelecionado;
}
public void setestadosSelecionado(HtmlSelectOneMenu estadosSelecionado) {
this.estadosSelecionado = estadosSelecionado;
}
// select para nivelgestao
private HtmlSelectOneMenu nivelgestaoSelecionado;
public HtmlSelectOneMenu getnivelgestaoSelecionado() {
return nivelgestaoSelecionado;
}
public void setnivelgestaoSelecionado(
HtmlSelectOneMenu nivelgestaoSelecionado) {
this.nivelgestaoSelecionado = nivelgestaoSelecionado;
}
// select para municipiosrr
private HtmlSelectOneMenu municipiosrrSelecionado;
public HtmlSelectOneMenu getmunicipiosrrSelecionado() {
return municipiosrrSelecionado;
}
public void setmunicipiosrrSelecionado(
HtmlSelectOneMenu municipiosrrSelecionado) {
this.municipiosrrSelecionado = municipiosrrSelecionado;
}
public OrgaoGestor getOrgaoGestor() {
return orgaogestor;
}
// lista de orgaos gestores
public List<OrgaoGestor> getOrgaosGestores() {
System.out.println("Carregando a lista de orgaos gestores ...");
Session session = HibernateUtil.currentSession();
Dao<OrgaoGestor> dao = new Dao<OrgaoGestor>(session, OrgaoGestor.class);
return dao.list();
}
// select para estadosHandler
private EstadosHandler pegaEstadosHandler() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ELResolver resolver = facesContext.getApplication().getELResolver();
Object uf = resolver.getValue(elContext, null, "estadosHandler");
return (EstadosHandler) uf;
}
public List<SelectItem> getEstadosParaComboBox() {
List<SelectItem> lista = new ArrayList<SelectItem>();
// usaremos o id como valor e o nome como label para os SelectItem.
EstadosHandler handler = pegaEstadosHandler();
for (Estados e : handler.getListaEstados()) {
lista.add(new SelectItem(e.getCod_estado(), e.getUf()));
}
return lista;
}
// select para municipiosrrHandler
private MunicipiosRRHandler pegaMunicipiosRRHandler() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ELResolver resolver = facesContext.getApplication().getELResolver();
Object m = resolver.getValue(elContext, null, "municipiosRRHandler");
return (MunicipiosRRHandler) m;
}
public List<SelectItem> getMunicipiosRRParaComboBox() {
List<SelectItem> lista = new ArrayList<SelectItem>();
// usaremos o id como valor e o nome como label para os SelectItem.
MunicipiosRRHandler handler = pegaMunicipiosRRHandler();
for (MunicipiosRR m : handler.getListaMunicipiosRR()) {
lista
.add(new SelectItem(m.getCod_municipiosrr(), m
.getMunicipios()));
}
return lista;
}
// select para nivelgestaoHandler
private NivelGestaoHandler pegaNivelGestaoHandler() {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ELResolver resolver = facesContext.getApplication().getELResolver();
Object ng = resolver.getValue(elContext, null, "nivelgestaoHandler");
return (NivelGestaoHandler) ng;
}
public List<SelectItem> getNivelGestaoParaComboBox() {
List<SelectItem> lista = new ArrayList<SelectItem>();
// usaremos o id como valor e o nome como label para os SelectItem.
NivelGestaoHandler handler = pegaNivelGestaoHandler();
for (NivelGestao ng : handler.getListaNiveisGestao()) {
lista.add(new SelectItem(ng.getCod_nivelgestao(), ng.getTipo()));
}
return lista;
}
public String salva() {
System.out.println("Adicionando: " + orgaogestor.getNome());
Session session = HibernateUtil.currentSession();
Dao<OrgaoGestor> orgaogestorDao = new Dao<OrgaoGestor>(session,
OrgaoGestor.class);
Dao<Estados> estadosDao = new Dao<Estados>(session, Estados.class);
Dao<MunicipiosRR> municipiosrrDao = new Dao<MunicipiosRR>(session,
MunicipiosRR.class);
Dao<NivelGestao> nivelgestaoDao = new Dao<NivelGestao>(session,
NivelGestao.class);
// estados
Long id_estados = Long
.valueOf(estadosSelecionado.getValue().toString());
Estados uf = estadosDao.load(id_estados);
orgaogestor.setEstados_cod_estados(id_estados);
// municipios
Long id_municipios = Long.valueOf(municipiosrrSelecionado.getValue()
.toString());
MunicipiosRR m = municipiosrrDao.load(id_municipios);
orgaogestor.setMunicipiosrr_cod_municipiosrr(id_municipios);
// nivelgestao
Long id_nivelgestao = Long.valueOf(nivelgestaoSelecionado.getValue()
.toString());
NivelGestao ng = nivelgestaoDao.load(id_nivelgestao);
orgaogestor.setNivelgestao_cod_nivelgestao(id_nivelgestao);
orgaogestorDao.merge(this.orgaogestor);
this.orgaogestor = new OrgaoGestor();
return "sucesso";
}
public void escolheOrgaoGestor(ActionEvent event) {
UIComponent link = event.getComponent();
UIParameter param = (UIParameter) link.findComponent("editCod");
Long id = (Long) param.getValue();
Session session = HibernateUtil.currentSession();
Dao<OrgaoGestor> dao = new Dao<OrgaoGestor>(session, OrgaoGestor.class);
this.orgaogestor = dao.load(id);
}
public void validaCase(FacesContext fc, UIComponent component, Object value) {
String valor = value.toString();
if (!valor.matches("[A-Z].*")) {
throw new ValidatorException(new FacesMessage(
"Inicie o nome com letra maiúscula!"));
}
}
}[/code]
JSP do orgaogestor
[code]<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f”%>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h”%>
<%@ taglib uri=“http://richfaces.org/a4j” prefix=“a4j” %>
<%@ taglib uri=“http://richfaces.org/rich” prefix=“rich” %>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>Cadastro de Órgãos Gestores</title>
</head>
<body>
<f:subview id="orgaogestor">
<h:form>
<h:panelGrid>
<h:form id="orgaogestor">
<h:outputText value="Orgão Gestor: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.nome}" required="true" validator="#{orgaogestorHandler.validaCase}">
<f:validateLength minimum="5" />
</h:inputText>
<br/>
<h:outputText value="Endereço: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.endereco}" required="true" validator="#{orgaogestorHandler.validaCase}">
<f:validateLength minimum="5" />
</h:inputText>
<h:outputText value="Complemento: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.endereco_complemento}" required="false" >
</h:inputText>
<h:outputText value="Fone: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.fone}" required="true" >
<f:validateLength minimum="5" />
</h:inputText>
<h:outputText value="Fax: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.fax}" required="true" >
</h:inputText>
<h:outputText value="E-mail: " />
<h:inputText value="#{orgaogestorHandler.orgaoGestor.email}" required="true" >
</h:inputText>
<h:outputText value="Município: " /> <h:selectOneMenu binding="#{orgaogestorHandler.municipiosrrSelecionado}"> <f:selectItem itemValue="0" itemLabel="Selecione"/> <f:selectItems value="#{orgaogestorHandler.municipiosRRParaComboBox}" /> </h:selectOneMenu>
<h:outputText value="UF: " />
<h:selectOneMenu binding="#{orgaogestorHandler.estadosSelecionado}">
<f:selectItem itemValue="1" itemLabel="Selecione"/>
<f:selectItems value="#{orgaogestorHandler.estadosParaComboBox}" />
</h:selectOneMenu>
<h:outputText value="Nivel de Gestão: " />
<h:selectOneMenu binding="#{orgaogestorHandler.nivelgestaoSelecionado}">
<f:selectItem itemValue="2" itemLabel="Selecione"/>
<f:selectItems value="#{orgaogestorHandler.nivelGestaoParaComboBox}" />
</h:selectOneMenu>
<h:commandButton value="Salvar" action="#{orgaogestorHandler.salva}" />
</h:form>
<rich:spacer height="10"/>
<rich:separator height="1" lineType="dotted"/>
<rich:spacer height="10"/>
<jsp:include page="listaorgaogestor.jsp" />
</h:panelGrid>
</h:form>
</f:subview>
</body>
</html>[/code]
JSP da listaorgaogestor
[code]<%@ taglib uri=“http://java.sun.com/jsf/core” prefix=“f”%>
<%@ taglib uri=“http://java.sun.com/jsf/html” prefix=“h”%>
<%@ taglib uri=“http://richfaces.org/a4j” prefix=“a4j” %>
<%@ taglib uri=“http://richfaces.org/rich” prefix=“rich” %>
<html>
<head>
<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>
<title>listaorgaogestor</title>
</head>
<body>
<f:subview id=“listaorgaogestor”>
<h:form>
<rich:dataTable value="#{orgaogestorHandler.orgaosGestores}" var=“f” rendered="#{not empty orgaogestorHandler.orgaosGestores}" rows=“5” id=“orgaogestor”>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Código”/>
</f:facet>
<h:outputText value="#{f.cod_orgaogestor}"/>
</h:column>
<h:column>
<f:facet name=“header”>
<h:outputText value=“Nome”/>
</f:facet>
<h:outputText value="#{f.nome}"/>
</h:column>
<h:column>
<f:facet name="header">
<h:outputText value="Alterar"/>
</f:facet>
<h:commandLink actionListener="#{orgaogestorHandler.escolheOrgaoGestor}">
<h:outputText value="(alterar)"/>
<f:param id="editCod" name="cod" value="#{f.cod_orgaogestor}"/>
</h:commandLink>
</h:column>
<%--Rodape com o paginador--%>
<f:facet name="footer">
<rich:datascroller/>
</f:facet>
</rich:dataTable>
</h:form>
</f:subview>
</body>
</html>[/code]