fuwang

           

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

          hibernate3.x的hql不能在weblogic8.1上€正確解析的解決方法
          轉(zhuǎn)載1
          hibernate3.0后hql采用了antlr(ANother Tool for Language Recogition)機制,由于Weblogic默認啟動另外版本的antlr并且不能在啟動后加載其他的antlr包。所以只能在weblogic啟動時強制加載自己的antlr包。weblogic的啟動參數(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 參考資料如下:錯誤原因: 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

          在運行過程中出現(xiàn)
          ClassNotFoundException: org.hibernate.hql.ast.HqlToken 錯誤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)使用的時候出現(xiàn)了不支持條件輸入中文的情況。選擇(2)可以支持輸入中文,但沒法解釋批量更新語句了
          hibernate3中需要用到antlr,然而這個包在weblogic.jar中已經(jīng)包含了antrl類庫,就會產(chǎn)生一些類加載的錯誤,無法找到在war或者ear中的hibernate3.jar。
          出現(xiàn)這個錯誤之后,antlr會調(diào)用System.exit(),這樣weblogic就會中止服務(wù)。
          解決方法:
          1.是在hibernate.properties文件中增加屬性:hibernate.query.factory_class,屬性的值是org.hibernate.hql.classic.ClassicQueryTranslatorFactory,這樣就可以解決問題了。
          但是部分功能會有問題,譬如
          但本系在批量刪除和更新會有問題,本系統(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的同一目錄(注:替換之后沒做做過嚴格測試,尚不知是否有后遺癥)
          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) 評論(0)  編輯  收藏 所屬分類: Hibernate


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


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

          導(dǎo)航

          統(tǒng)計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 绵阳市| 馆陶县| 加查县| 义乌市| 青铜峡市| 原平市| 淮阳县| 陇川县| 鹤峰县| 旅游| 黑河市| 崇左市| 玛纳斯县| 凤城市| 柳河县| 富平县| 尼勒克县| 庆城县| 高陵县| 苍山县| 新邵县| 逊克县| 玛沁县| 太原市| 钦州市| 普宁市| 林甸县| 宿迁市| 长寿区| 依安县| 富源县| 赤城县| 全州县| 沙雅县| 新乐市| 阿拉善右旗| 岳阳市| 嘉黎县| 尖扎县| 吴旗县| 黎平县|