Hibernate配置過程可能發生的問題及解決方法(轉)

  Hibernate配置過程可能發生的問題及解決方法 收藏

1.問題:Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentExceptionjava

    at HibernateTest.main(HibernateTest.java:14)node

方法:添加dom4j.jar(解析hibernate.cfg.xml文件)mysql

 

2.問題:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactorysql

    at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:116)apache

    at HibernateTest.main(HibernateTest.java:14)緩存

方法:添加commons-logging.jar(記錄解析過程)服務器

 

3.問題:Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections/SequencedHashMapdom

方法:添加commons-collections.jar(在解析映射文件時,須要把全部持久化對象的定義放在一個HashMap)fetch

 

4.問題:Exception in thread "main" java.lang.NoClassDefFoundError: net/sf/ehcache/CacheExceptionspa

方法:添加ehcache.jar(高速緩存,提升存取速度)

 

5.問題:2009-2-22 23:45:40 net.sf.ehcache.config.Configurator configure

警告: No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/F:/MyJava/Hibernate/lib/ehcache-1.1.jar!/ehcache-failsafe.xml

Exception in thread "main" java.lang.NoClassDefFoundError

方法:ehcache-1.1.jar解壓,把其中的ehcache-failsafe.xml改爲ehcache.xml

 

6.問題:Caused by: java.lang.ClassNotFoundException: net.sf.cglib.transform.impl.InterceptFieldEnabled

方法:添加cglib-full-2.0.02.jar

 

7.問題:Caused by: java.lang.NoSuchMethodError: net.sf.cglib.proxy.Enhancer.setInterceptDuringConstruction(Z)V

方法:添加cglib-nodep-2.1_3.jar

 

8.問題:Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/Synchronization

方法:添加jta.jar(事務處理)

 

9.問題:Exception in thread "main" java.lang.NoClassDefFoundError: antlr/ANTLRException

方法:添加antlr-2.7.5h3.jar

 

10問題:Caused by: java.sql.SQLException: The statement (1) has no open cursor.

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2901)

    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:773)

方法: <!-- <property name="jdbc.fetch_size">50 </property>  -->
把上面這個屬性按上面這樣註釋掉就能夠了. (若是mysql-connector的版本早於3.2.1並且服務器的版本早於5.0.3,"setFetchSize()"是沒有效果的.)

相關文章
相關標籤/搜索