项目 在 tomcat 下 正常,在 weblogic 下 报 错误
org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
网上 查询 得知 weblogic 使用的jar 包 和 hibernate3 使用的 antlr-2.7.6.jar 包 冲突。
hibernate 3 翻译 hql 语句 使用的 jar 包 antlr-2.7.6.jar 未加载 成功 ,所以使用 hql 的 查询出错。
解决办法 就是 让 weblogic 优先加载hibernate 的 jar
一种 办法 是在项目的 WEB-INF 中 增加 weblogic.xml ,内容 为
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE weblogic-web-app PUBLIC "-//BEA Systems, Inc.//DTD Web Application 8.1//EN" "http://www.bea.com/servers/wls810/dtd/weblogic810-web-jar.dtd">
<weblogic-web-app>
<container-descriptor>
<prefer-web-inf-classes>true</prefer-web-inf-classes>
</container-descriptor>
</weblogic-web-app>
另一种 办法 是将 hibernate 中的antlr-2.7.6.jar 放入 weblogic 使用的 jdk 的 \jre\lib\ext 文件夹 下
让与jdk 一起加载