在配置中加以下屬性就可以解決
<prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
使用Spring+hibernate如下
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.generate_statistics">true</prop>
<!-- 解決weblogic拋出的ClassNotFoundException: org.hibernate.hql.ast.HqlToken異常-->
<prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>
</props>
</property>
上面這樣還是使用Hibernate2的查詢機制,根據回復經驗證后可以按下面設置使用hibernate3的查詢機制:
1、拷貝Hibernate3里帶的包antlr-2.7.5H3.jar到%WL_HOME%\server\lib下
2、修改startWebLogic.cmd :
在set CLASSPATH之前加上下面一句:
set PRE_CLASSPATH=%WL_HOME%\server\lib\antlr-2.7.5H3.jar;
在set CLASSPATH之后加上下面一句:
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
一切OK!
具體原因可參照此頁:http://dev2dev.bea.com/blog/pmalani/archive/2005/07/configuring_web.html