最近在项目中用weblogic跑Spring+hibernate的运用(在tomcat中正常运行)

抛出如下的异常

org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.datastage.model.TmdDatastageXm project where project.jqbh=?]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.datastage.model.TmdDatastageXm project where project.jqbh=?]org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.datastage.model.TmdDatastageXm project where project.jqbh=?]
        at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:57)
        at antlr.CharScanner.setTokenObjectClass(CharScanner.java:340)
        at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:31)

使用Spring+hibernate如下xml 代码
<property name="hibernateProperties">  
      <props>  
        <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>  
        <prop key="hibernate.show_sql">false</prop>  
        <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>            
      </props>  

    </property>  


在配置中加以下属性就可以解决
org.hibernate.hql.ast.ASTQueryTranslatorFactory

 

新增后的xml 代码
  
<property name="hibernateProperties">  
      <props>  
        <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>  
        <prop key="hibernate.show_sql">false</prop>  
        <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>  
        <prop key="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</prop>  
      </props>  
    </property>  

 

注:如果这样的话,很多hb 3的hql语法就不能用了,比如delete。把antlr-x.x.xx.jar放到weblogic的启动classpath里(weblogic.jar之前)即可

相关文章:

  • 2021-06-26
  • 2022-02-03
  • 2021-11-21
  • 2021-12-08
  • 2022-12-23
  • 2021-05-21
  • 2021-11-25
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2022-12-23
  • 2021-09-05
  • 2022-02-08
  • 2021-12-06
相关资源
相似解决方案