尝试休眠并按照手册中的说明进行操作。但它不起作用。
package util;
//imports
public class HibernateUtil {
private static SessionFactory sessionFactory = null;
static {
try {
System.out.println("HU 01");
Configuration configuration = new Configuration();
System.out.println("HU 02");
configuration.configure();
System.out.println("HU 03");
//creates the session factory from hibernate.cfg.xml
ServiceRegistry serviceRegistry = new ServiceRegistryBuilder().applySettings(configuration.getProperties()).buildServiceRegistry();
System.out.println("HU 04");
sessionFactory = configuration.buildSessionFactory(serviceRegistry);
System.out.println("HU 05");
} catch (Exception e) {
System.out.println("HU 06");
e.printStackTrace();
}
}
public static SessionFactory getSessionFactory() {
System.out.println("HU 00");
return sessionFactory;
}
}
我有下一个日志(放置 System.out... 无处不在):
Main class starts.
Factory initialised.
Factory.Entity initialised.
ImplDAO 1
HU 01
ImplDAO 8
Exception in thread "main" java.lang.NoClassDefFoundError: org/jboss/logging/BasicLogger
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:176)
at util.HibernateUtil.<clinit>(HibernateUtil.java:14)
at dao.impl.ImplDAO.setData(ImplDAO.java:27)
at service.MainClass.main(MainClass.java:17)
“HU 01”出现在控制台中,“HU 02”没有。所以,我想,我遇到了一些 hibernate.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>
<property name="hibernate.connection.driver_class">oracle.jdbc.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@localhost:1251:XE</property>
<property name="hibernate.connection.username">SYSTEM</property>
<property name="hibernate.connection.password">12345</property>
<property name="hibernate.connection.pool_size">10</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="show_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.connection.autocommit">false</property>
<property name="current_session_context_class">thread</property>
<mapping class="logic.EntityClass" />
</session-factory>
</hibernate-configuration>
我的环境:
Hibernate 4.1
WebLogic Server 11gR1
Oracle DataBase 11g Express Edition
Eclipse Juno
JRE: jdk1.7.0_09
(same thing with Oracle WebLogic Server 11gR1 (10.3.2) JRE)
任何想法?