Ola amigos, eu fiz um sistema de cadastro de usuários utilziando o mysql, fui migrar de banco, estou tendo um problema !
aqui é meu hibernater.cfg.xml
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<!--Configurações do hibernate: mapeamento dos objetos -->
<hibernate-configuration>
<!--session-factory atraves dele é que eu faço o mapeamento e as configurações do hibernate -->
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">tecnologia</property>
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/login</property>
<property name="hibernate.connection.username">123</property>
<property name="hibernate.dialect">org.hibernate.dialect.ProgressDialect</property>
<property name="hibernate.show_sql">false</property>
<!--Mapeamento da class Usuario -->
<mapping class="com.br.joaoleno.usuario.Usuario"></mapping>
</session-factory>
</hibernate-configuration>
aqui é o erro que estar dando
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: org.hibernate.HibernateException: No CurrentSessionContext configured!
com.br.joaoleno.web.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:44)
root cause
org.hibernate.HibernateException: No CurrentSessionContext configured!
org.hibernate.impl.SessionFactoryImpl.getCurrentSession(SessionFactoryImpl.java:696)
com.br.joaoleno.web.filter.HibernateSessionRequestFilter.doFilter(HibernateSessionRequestFilter.java:28)
note The full stack trace of the root cause is available in the Apache Tomcat/7.0.22 logs.
e aqui é o arquivo referente ao erro
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.br.joaoleno.web.filter;
import javax.servlet.*;
import org.hibernate.SessionFactory;
import com.br.joaoleno.util.*;
import java.io.IOException;
import java.rmi.ServerException;
/**
*
* @author JOHN LENON
*/
public class HibernateSessionRequestFilter implements Filter {
private SessionFactory sf;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
sf = HibernateUtil.getSessionFactory();
}
@Override
public void doFilter(ServletRequest sRq, ServletResponse sRp, FilterChain chain) throws IOException, ServletException {
try{
sf.getCurrentSession().beginTransaction();
chain.doFilter(sRq, sRp);
sf.getCurrentSession().getTransaction().commit();
sf.getCurrentSession().close();
}
catch(Throwable erro){
try{
if(sf.getCurrentSession().getTransaction().isActive()){
sf.getCurrentSession().getTransaction().rollback();
}
}
catch(Throwable ex){
System.out.println("Erro .: "+ex.getMessage());
ex.printStackTrace();
}
throw new ServletException(erro);
}
}
@Override
public void destroy() {
System.out.println("Sessão finalizada");
}
}
Alguem sabe o que tem de errado ? já olhei bem direitinho e não vejo erro, lembrando que eu ja coloquei o jar do postgresql!!!
alguem ajuda ?
