Erro ao acessar pagina JSF …javax.servlet.ServletException: javax.servlet.ServletException: null source
financeiro.web.filter.ConexaoHibernateFilter.doFilter(ConexaoHibernateFilter.java:44)
Ao digitar no browser :
http://localhost:8080/FinanceiroWeb/restrito/conta.jsf
me da o erro abaixo
TTP 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: null source
financeiro.web.filter.ConexaoHibernateFilter.doFilter(ConexaoHibernateFilter.java:44)
root cause
javax.servlet.ServletException: null source
javax.faces.webapp.FacesServlet.service(FacesServlet.java:321)
financeiro.web.filter.ConexaoHibernateFilter.doFilter(ConexaoHibernateFilter.java:32)
root cause
java.lang.IllegalArgumentException: null source
java.util.EventObject.<init>(Unknown Source)
javax.faces.event.SystemEvent.<init>(SystemEvent.java:67)
javax.faces.event.ComponentSystemEvent.<init>(ComponentSystemEvent.java:69)
javax.faces.event.PostRestoreStateEvent.<init>(PostRestoreStateEvent.java:69)
com.sun.faces.lifecycle.RestoreViewPhase.deliverPostRestoreStateEvent(RestoreViewPhase.java:256)
com.sun.faces.lifecycle.RestoreViewPhase.execute(RestoreViewPhase.java:245)
com.sun.faces.lifecycle.Phase.doPhase(Phase.java:97)
com.sun.faces.lifecycle.RestoreViewPhase.doPhase(RestoreViewPhase.java:107)
com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:114)
javax.faces.webapp.FacesServlet.service(FacesServlet.java:308)
financeiro.web.filter.ConexaoHibernateFilter.doFilter(ConexaoHibernateFilter.java:32)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.4 logs.
Apache Tomcat/7.0.4
pagina.xhtml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:sec="http://www.springframework.org/security/facelets/tags"
>
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Cadastro de contas</title>
<h:/head>
<h:body>
<h1>Cadastro de contas</h1>
<h:/body>
</html>
ConexaoHibernateFilter.java
import java.io.IOException;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import org.hibernate.SessionFactory;
import financeiro.util.HibernateUtil;
public class ConexaoHibernateFilter implements Filter{
private SessionFactory sf;
public void init(FilterConfig arg0) throws ServletException {
this.sf = HibernateUtil.getSessionfactory();
}
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
FilterChain chain) throws IOException, ServletException {
try {
this.sf.getCurrentSession().beginTransaction();
chain.doFilter(servletRequest, servletResponse);
this.sf.getCurrentSession().getTransaction().commit();
this.sf.getCurrentSession().close();
} catch (Throwable ex) {
try {
if(this.sf.getCurrentSession().getTransaction().isActive()){
this.sf.getCurrentSession().getTransaction().rollback();
}
} catch (Throwable t) {
t.printStackTrace();
}
throw new ServletException(ex);
}
}
}