Erro no meu JSF

2 respostas
E

Estou tendo um erro, é o seguinte:

página index.jsp
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Folha de Pagamento WEB - CRECI/SP</title>
    </head>
    
   <f:view>
        <h:form>
            <center>
                <h1>Folha de Pagamento WEB</h1>
                <br>
                <h3>
                    <h:commandButton action="#{beneficios.buscar}" value="Beneficios"/>
                
                </h3>
            </center>
        </h:form>
    </f:view>    
</html>
meu método buscar:
public String buscar() throws SQLException {
        String result_busca = BUSCA_INVALIDA;
        
		try {
			List<Beneficios> lista = dao.listaTudo();
			if (lista.equals("")) {
				result_busca = BUSCA_INVALIDA;
            }else {
            	id 	 		 = beneficios.getId();
	            descricao  	 = beneficios.getDescricao(); 
	            funcionario  = beneficios.getFuncionario(); 
	            dependente   = beneficios.getDependente();
	            result_busca = BUSCA_VALIDA;                
            }
		}catch(org.hibernate.ObjectNotFoundException e) {
			System.out.println("Erro ou não existe!");
			result_busca = BUSCA_INVALIDA;
		}        
        
        return result_busca;
    }
Página para exibir os resultados:
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<html>
	<head>
		<title>Beneficios</title>
	</head>
	<body>

		<f:view>
			<center><strong><h1>Tabela de Beneficios</h1></strong></center>
        <h:form>
            <table border>
                <tr>
					<td>Ítem</td>
                    <td>Descrição</td>
                    <td>Funcionário</td>
                    <td>Dependente</td>
                </tr>
                
                <tr>
                <td><input type="checkbox" value="ON"/></td>	
                    <td>
                    	<h:outputLink value="/insereAlteraBeneficios.jsp">
                    		<f:verbatim>
		                        <h:outputText value="#{beneficios.descricao}">
    		                    </h:outputText>
    		                </f:verbatim>
    		            </h:outputLink>
    	                    
                    </td>

                    <td>
                    	<h:outputLink value="">
                    		<f:verbatim>
		                        <h:outputText value="#{beneficios.funcionario}">
    		                    </h:outputText>
    		                </f:verbatim>
    		            </h:outputLink>
                    </td>

                    <td>
                    	<h:outputLink value="">
                    		<f:verbatim>
	    	                	<h:outputText value="#{beneficios.dependente}">
    	    	            	</h:outputText>
    	    	           	</f:verbatim>
    	    	        </h:outputLink>
                    </td>
                </tr>
            </table>
            <p>
                <h:commandButton value="Insere" action="insereAlteraBeneficios.jsp"/>
            </p>
            
        </h:form>
        <br>
        <h:outputLink value="index.jsf">
            <f:verbatim>voltar</f:verbatim>
        </h:outputLink>			
		</f:view>
	</body>	
</html>

meu faces-config.xml:

<?xml version="1.0"?>
<!DOCTYPE faces-config PUBLIC "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.1//EN"
                              "http://java.sun.com/dtd/web-facesconfig_1_1.dtd">
<faces-config>
 <managed-bean>
  <managed-bean-name>beneficios</managed-bean-name>
  <managed-bean-class>br.com.creci.fp.hibernate.Beneficios</managed-bean-class>
  <managed-bean-scope>request</managed-bean-scope>
 </managed-bean>
 <navigation-rule>
  <from-view-id>/index.jsp</from-view-id>
  <navigation-case>
   <from-outcome>success</from-outcome>
   <to-view-id>/beneficios.jsp</to-view-id>
  </navigation-case>
  <navigation-case>
   <from-outcome>failure</from-outcome>
   <to-view-id>/falha_busca.jsp</to-view-id>
  </navigation-case>
 </navigation-rule>
</faces-config>

e o seguinte erro está acontecendo qdo clico no botão da index.jsp:

javax.servlet.ServletException: #{beneficios.buscar}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/hibernate/ObjectNotFoundException
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:209)


root cause 

javax.faces.FacesException: #{beneficios.buscar}: javax.faces.el.EvaluationException: java.lang.NoClassDefFoundError: org/hibernate/ObjectNotFoundException
	com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:78)
	javax.faces.component.UICommand.broadcast(UICommand.java:312)
	javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
	javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
	com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
	com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
	com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
	javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)

2 Respostas

vanderlanio

pelo que me parece seu erro esta na consulta ( no acesso com hibernate ) e nao no jsf ele nao esta encntrando a classe
org.hibernate.ObjectNotFoundException, troque por um exception e teste novamente… e print a excecao.

E

eu mudei do

}catch(org.hibernate.ObjectNotFoundException e) {

para

}catch(Exception e) {

e o seguinte erro ocorreu:

javax.servlet.ServletException: #{beneficios.buscar}: javax.faces.el.EvaluationException: java.lang.StackOverflowError

Criado 12 de setembro de 2006
Ultima resposta 12 de set. de 2006
Respostas 2
Participantes 2