fuwang

           

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

          hibernate3.x的hql不能在weblogic8.1上€正確解析的解決方法
          轉載1
          hibernate3.0后hql采用了antlr(ANother Tool for Language Recogition)機制,由于Weblogic默認啟動另外版本的antlr并且不能在啟動后加載其他的antlr包。所以只能在weblogic啟動時強制加載自己的antlr包。weblogic的啟動參數是在startWeblogic.cmd中設置的。我修改該文件:添加 @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.

          轉載2

          在運行過程中出現
          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)否則不能解釋批量更新的語句,當使用的時候出現了不支持條件輸入中文的情況。選擇(2)可以支持輸入中文,但沒法解釋批量更新語句了
          hibernate3中需要用到antlr,然而這個包在weblogic.jar中已經包含了antrl類庫,就會產生一些類加載的錯誤,無法找到在war或者ear中的hibernate3.jar。
          出現這個錯誤之后,antlr會調用System.exit(),這樣weblogic就會中止服務。
          解決方法:
          1.是在hibernate.properties文件中增加屬性:hibernate.query.factory_class,屬性的值是org.hibernate.hql.classic.ClassicQueryTranslatorFactory,這樣就可以解決問題了。
          但是部分功能會有問題,譬如
          但本系在批量刪除和更新會有問題,本系統不采用
          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 扶王 閱讀(926) 評論(0)  編輯  收藏 所屬分類: Hibernate

          導航

          統計

          常用鏈接

          留言簿(1)

          隨筆分類

          隨筆檔案

          搜索

          積分與排名

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 通辽市| 祁门县| 嵩明县| 桃园市| 灵武市| 新乡县| 甘孜| 龙南县| 彭山县| 砚山县| 黄平县| 鄂温| 伊吾县| 瑞丽市| 丰顺县| 扎囊县| 年辖:市辖区| 金乡县| 稷山县| 许昌县| 界首市| 临城县| 万州区| 保德县| 汕头市| 云和县| 进贤县| 三穗县| 密云县| 灌阳县| 太谷县| 思茅市| 宁夏| 岳阳县| 奎屯市| 大洼县| 武汉市| 梁河县| 丰原市| 略阳县| 改则县|