fuwang

           

          hibernate3.x的hql不能在weblogic8.1上正確解析的解決方法

          hibernate3.x的hql不能在weblogic8.1上€正確解析的解決方法
          轉(zhuǎn)載1
          hibernate3.0后hql采用了antlr(ANother Tool for Language Recogition)機(jī)制,由于Weblogic默認(rèn)啟動(dòng)另外版本的antlr并且不能在啟動(dòng)后加載其他的antlr包。所以只能在weblogic啟動(dòng)時(shí)強(qiáng)制加載自己的antlr包。weblogic的啟動(dòng)參數(shù)是在startWeblogic.cmd中設(shè)置的。我修改該文件:添加 @REM Set hibernate classpath set HIBERNATE_LIB=C:\bea\user_projects\domains\mydomain\applications\embed\WEB-INF\lib 在set CLASSPATH的最前面加上 set CLASSPATH=%HIBERNATE_LIB%\antlr-2.7.6rc1.jar 參考資料如下:錯(cuò)誤原因: If you get CharScanner; panic: ClassNotFoundException: org.hibernate.hql.ast.HqlToken - Hibernate 3.x includes a new query parser that doesn't run on Weblogic - the reason is a packaging error of ANTLR in Weblogic's boot classpath. Read the section in the Hibernate3 Migration Guide. Hibernate建議 Hibernate3 uses ANTLR for the new query parser. Unfortunately BEA Weblogic includes a version of ANTLR in the system classpath which will be loaded before any application libraries and, because Weblogic doesn't seem to support proper class loader isolation, will not see the Hibernate classes in the application's context. BEA seems to solve this issue by prefixing package names, but the distributed ANTLR doesn't have this prefix. Another source for this issue is the usage of Class.forName() in ANTLR itself. Until both parties have solved these issues we can only provide workarounds: Place all your Hibernate and dependent libraries on the application server's boot classpath or use the old query parser as described above.

          轉(zhuǎn)載2

          在運(yùn)行過程中出現(xiàn)
          ClassNotFoundException: org.hibernate.hql.ast.HqlToken 錯(cuò)誤weblogic異常退出。
          原因:
          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)否則不能解釋批量更新的語句,當(dāng)使用的時(shí)候出現(xiàn)了不支持條件輸入中文的情況。選擇(2)可以支持輸入中文,但沒法解釋批量更新語句了
          hibernate3中需要用到antlr,然而這個(gè)包在weblogic.jar中已經(jīng)包含了antrl類庫,就會(huì)產(chǎn)生一些類加載的錯(cuò)誤,無法找到在war或者ear中的hibernate3.jar。
          出現(xiàn)這個(gè)錯(cuò)誤之后,antlr會(huì)調(diào)用System.exit(),這樣weblogic就會(huì)中止服務(wù)。
          解決方法:
          1.是在hibernate.properties文件中增加屬性:hibernate.query.factory_class,屬性的值是org.hibernate.hql.classic.ClassicQueryTranslatorFactory,這樣就可以解決問題了。
          但是部分功能會(huì)有問題,譬如
          但本系在批量刪除和更新會(huì)有問題,本系統(tǒng)不采用
          2.將antlr-2.7.5H3.jar到Weblogic的pre_Classpath :用WinRar或Winzip打開C:\bea\weblogic81\server\lib\weblogic.jar 刪除里面的antlr目錄, 然后再antlr-2.7.5H3.jar放在weblogic.jar的同一目錄(注:替換之后沒做做過嚴(yán)格測(cè)試,尚不知是否有后遺癥)
          3. 1、拷貝Hibernate3里帶的包antlr-2.7.5H3.jar到%WL_HOME%\server\lib下
          2、修改% mydomain% \ startWebLogic.cmd :
          在set CLASSPATH之前加上下面一句:
          set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar;
          在set CLASSPATH之后加上下面一句:
          set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%

          posted on 2006-12-15 02:51 扶王 閱讀(930) 評(píng)論(0)  編輯  收藏 所屬分類: Hibernate


          只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


          網(wǎng)站導(dǎo)航:
           

          導(dǎo)航

          統(tǒng)計(jì)

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          搜索

          積分與排名

          最新評(píng)論

          閱讀排行榜

          評(píng)論排行榜

          主站蜘蛛池模板: 南华县| 丹东市| 永平县| 长丰县| 洱源县| 锦州市| 红原县| 本溪市| 资阳市| 谢通门县| 抚远县| 大余县| 嘉定区| 阳江市| 建始县| 河池市| 黄石市| 灌云县| 焉耆| 娄烦县| 禄丰县| 紫金县| 乌拉特后旗| 额敏县| 常德市| 大同市| 济源市| 峨山| 涟源市| 前郭尔| 青州市| 青神县| 晋城| 福安市| 衡南县| 重庆市| 图片| 罗城| 新巴尔虎左旗| 济源市| 南昌市|