Olá Pessoal, sei q este erro é bastante comum para quem utiliza principamente o hiberante
Eu começei a fazer um sistema bem basico para aprender e estou me batendo com esse erro.
Ele acontece provavelmente quando crio uma instancia da SessionFactory. Sei que pode ser varias coisas tipo jars, configuração no hibernate.cfg.xml etc
Por isso vou detalhar ao maximo para que possam me ajudar
Hiberante: hibernate-distribution-3.6.7.Final
Lib: antlr-2.7.6
commons-collections-3.2
commons-logging-1.0.4
dom4j-1.6.1
ejb3-persistence
hibernate3
hibernate-jpa-2.0-api-1.0.1.Final
javassist-3.12.0.GA
jta-1.1
log4j-1.2.16
slf4j-api-1.6.4
slf4j-simple-1.6.4
HiberanteUtils
package br.com.controlatudo.utils;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.slf4j.Logger;
public class HibernateUtils {
private static final SessionFactory sessionFactory = buildSessionFactory();
private static Logger logger = org.slf4j.LoggerFactory.getLogger(HibernateUtils.class);
private static SessionFactory buildSessionFactory() {
try {
return new Configuration().configure().buildSessionFactory();
} catch (Throwable ex) {
//logger.info("Criacao da fabrica de Sessoes falhou: " + ex);
System.err.println("Initial SessionFactory creation failed." + ex);
throw new ExceptionInInitializerError();
}
}
public static Session getSession(){
return sessionFactory.getCurrentSession();
}
}
GenericDAO
package br.com.controlatudo.daoImpl;
import java.util.List;
import org.hibernate.Session;
import br.com.controlatudo.dao.GenericDAO;
import br.com.controlatudo.dao.Persistencia;
import br.com.controlatudo.utils.HibernateUtils;
public class GenericDAOImpl<T extends Persistencia> implements GenericDAO<T>{
protected Session getSession(){
return HibernateUtils.getSession();
}
@Override
public T salvar(T persistencia) {
getSession().save(persistencia);
return persistencia;
}
}
hiberante.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">
<hibernate-configuration>
<session-factory name="">
<property name="hibernate.connection.url">jdbc:postgresql://localhost:5432/controlatudo</property>
<property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
<property name="hibernate.connection.password">adminadmin</property>
<property name="hibernate.connection.username">postgres</property>
<property name="hibernate.default_schema">domain</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.hbm2ddl.auto">create</property>
<mapping class="br.com.controlatudo.entidades.Usuario" />
</session-factory>
</hibernate-configuration>
Se alguem puder me auxiliar
Procurei no GUJ algo relacionado, encontrei várias coisas, mas nenhuma me ajudou
Obrigado