Weblogic ClassNotFoundException: org.hibernate.hql.ast.HqlToken

Weblogic中hibernate3異常:

  ClassNotFoundException: org.hibernate.hql.ast.HqlToken


Hibernate3.0 採用新的基於ANTLR的HQL/SQL查詢翻譯器,在Hibernate的配置文件中,
               hibernate.query.factory_class屬性用來選擇查詢翻譯器。
                             1、Hibernate3.0的查詢翻譯器:
                                        hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory
                             2、Hibernate2.1的查詢翻譯器
                                        hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory 
                             3.0的批量更新和刪除功能,
                                     (1)不能解釋批量更新的語句,當使用的時候出現了不支持條件輸入中文的情況。
                                     (2)可以支持輸入中文,但沒法解釋批量更新語句了
                           hibernate3中需要用到antlr,然而這個包在weblogic.jar中已經包含了antrl類庫,
                         就會產生一些類加載的錯誤,無法找到在war或者ear中的hibernate3.jar。
                         出現這個錯誤之後,antlr會調用System.exit(),這樣weblogic就會中止服務。
 
   解決方法也很簡單,就是添加
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>

<?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">

<!-- Generated by MyEclipse Hibernate Tools.                   -->
<hibernate-configuration>
<session-factory>
 <property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
 <property name="connection.url">jdbc:oracle:thin:@localhost:1521:mydb</property>
 <property name="connection.username">xxxx</property>
 <property name="connection.password">xxxx</property>
 <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
 <property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
 <mapping resource="xxxxx.hbm.xml" />
</session-factory>
</hibernate-configuration>


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章