I have a web project running with hibernate 4.3.11, however when substitute the lib to 5.0.1, the problem follows HibernateUtil. an anyone help me?
error javax.servlet.ServletException: Could not initialize class util.HibernateUtil
package util;
import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.boot.registry.StandardServiceRegistryBuilder; import org.hibernate.cfg.Configuration; import org.hibernate.service.ServiceRegistry; public class HibernateUtil { private static SessionFactory sessionFactory = buildSessionFactory(); private static SessionFactory buildSessionFactory() { try { if (sessionFactory == null) { Configuration configuration = new Configuration().configure(HibernateUtil.class.getResource("/hibernate.cfg.xml")); StandardServiceRegistryBuilder serviceRegistryBuilder = new StandardServiceRegistryBuilder(); serviceRegistryBuilder.applySettings(configuration.getProperties()); ServiceRegistry serviceRegistry = serviceRegistryBuilder.build(); sessionFactory = configuration.buildSessionFactory(serviceRegistry); } return sessionFactory; } catch (Throwable ex) { System.err.println("Erro criacao session Facotry :" + ex); throw new ExceptionInInitializerError(ex); } } public static Session getSessionFactory() { return sessionFactory.openSession(); } public static void shutdown() { getSessionFactory().close(); }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property> <property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property> <property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1521:XE</property> <property name="hibernate.connection.username">user</property> <property name="hibernate.connection.password">pass</property> <property name="hibernate.hbm2ddl.auto">validate</property> <property name="hibernate.show_sql">true</property> <mapping class="entidades.LoginWeb"/> </session-factory> </hibernate-configuration>
|