Problemas do tipo EvaluationException

1 resposta
Kleber-rr
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:
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)

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.

@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;
	}

}
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!"));
		}
	}

}
JSP do orgaogestor
<%@ 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/>
		&lt;h:outputText value="Endereço: " /&gt;
		
		&lt;h:inputText value="#{orgaogestorHandler.orgaoGestor.endereco}" required="true" validator="#{orgaogestorHandler.validaCase}"&gt;
			&lt;f:validateLength minimum="5" /&gt;
		&lt;/h:inputText&gt;
<br/>

		&lt;h:outputText value="Complemento: " /&gt;
		
		&lt;h:inputText value="#{orgaogestorHandler.orgaoGestor.endereco_complemento}" required="false" &gt;

		&lt;/h:inputText&gt;
<br/>
		&lt;h:outputText value="Fone: " /&gt;
		
		&lt;h:inputText value="#{orgaogestorHandler.orgaoGestor.fone}" required="true" &gt;
			&lt;f:validateLength minimum="5" /&gt;
		&lt;/h:inputText&gt;
<br/>
		&lt;h:outputText value="Fax: " /&gt;
		
		&lt;h:inputText value="#{orgaogestorHandler.orgaoGestor.fax}" required="true" &gt;
			
		&lt;/h:inputText&gt;
<br/>

		&lt;h:outputText value="E-mail: " /&gt;
		
		&lt;h:inputText value="#{orgaogestorHandler.orgaoGestor.email}" required="true" &gt;
			
		&lt;/h:inputText&gt;
<br/>
		&lt;h:outputText value="Município: " /&gt;
		&lt;h:selectOneMenu binding="#{orgaogestorHandler.municipiosrrSelecionado}"&gt;
				&lt;f:selectItem itemValue="0" itemLabel="Selecione"/&gt;
				&lt;f:selectItems value="#{orgaogestorHandler.municipiosRRParaComboBox}" /&gt;
		&lt;/h:selectOneMenu&gt;
		
		&lt;h:outputText value="UF: " /&gt;		
		&lt;h:selectOneMenu binding="#{orgaogestorHandler.estadosSelecionado}"&gt;
				&lt;f:selectItem itemValue="1" itemLabel="Selecione"/&gt;
				&lt;f:selectItems value="#{orgaogestorHandler.estadosParaComboBox}" /&gt;
		&lt;/h:selectOneMenu&gt;		
	
	&lt;h:outputText value="Nivel de Gestão: " /&gt;		
		&lt;h:selectOneMenu binding="#{orgaogestorHandler.nivelgestaoSelecionado}"&gt;
				&lt;f:selectItem itemValue="2" itemLabel="Selecione"/&gt;
				&lt;f:selectItems value="#{orgaogestorHandler.nivelGestaoParaComboBox}" /&gt;
		&lt;/h:selectOneMenu&gt;		
	
				
		
		&lt;h:commandButton value="Salvar" action="#{orgaogestorHandler.salva}" /&gt;
	&lt;/h:form&gt;
	
	&lt;rich:spacer height="10"/&gt;
	&lt;rich:separator height="1" lineType="dotted"/&gt;
	&lt;rich:spacer height="10"/&gt;
	
	&lt;jsp:include page="listaorgaogestor.jsp" /&gt;
	
	
	&lt;/h:panelGrid&gt;
	&lt;/h:form&gt;
	
	&lt;/f:subview&gt;

&lt;/body&gt;
&lt;/html&gt;
JSP da listaorgaogestor
&lt;%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%&gt;
&lt;%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%&gt;
&lt;%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %&gt;
&lt;%@ taglib uri="http://richfaces.org/rich" prefix="rich" %&gt;

&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
&lt;title&gt;listaorgaogestor&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;f:subview id="listaorgaogestor"&gt;
	&lt;h:form&gt;
		&lt;rich:dataTable value="#{orgaogestorHandler.orgaosGestores}" var="f" rendered="#{not empty orgaogestorHandler.orgaosGestores}" rows="5" id="orgaogestor"&gt;
		&lt;h:column&gt;
			&lt;f:facet name="header"&gt;
				&lt;h:outputText value="Código"/&gt;
			&lt;/f:facet&gt;
				&lt;h:outputText value="#{f.cod_orgaogestor}"/&gt;
		&lt;/h:column&gt;
		&lt;h:column&gt;
			&lt;f:facet name="header"&gt;
				&lt;h:outputText value="Nome"/&gt;
			&lt;/f:facet&gt;
				&lt;h:outputText value="#{f.nome}"/&gt;		
		&lt;/h:column&gt;

		&lt;h:column&gt;
			&lt;f:facet name="header"&gt;
				&lt;h:outputText value="Alterar"/&gt;
			&lt;/f:facet&gt;
			&lt;h:commandLink actionListener="#{orgaogestorHandler.escolheOrgaoGestor}"&gt;
			&lt;h:outputText value="(alterar)"/&gt;
				&lt;f:param id="editCod" name="cod" value="#{f.cod_orgaogestor}"/&gt;
			&lt;/h:commandLink&gt;
		&lt;/h:column&gt;
		
		&lt;%--Rodape com o paginador--%&gt;
		&lt;f:facet name="footer"&gt;
			&lt;rich:datascroller/&gt;
		&lt;/f:facet&gt;
		
		&lt;/rich:dataTable&gt;
	
	
	&lt;/h:form&gt;
&lt;/f:subview&gt;
&lt;/body&gt;
&lt;/html&gt;

1 Resposta

Kleber-rr

Pessoal, descobri o problema. Na verdade, o problema era no meu banco. Eu tinha um campo na tabela que era bolean, mas estava instanciando ele como String. hehehee
Coisa de iniciante.

Obrigado

Criado 10 de novembro de 2009
Ultima resposta 10 de nov. de 2009
Respostas 1
Participantes 1