weblogic 下异常 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
项目之前在 Tomcat 环境下一直都正常运行,今天应客户要求需要迁移到 webLogic 10.3.6 下, 部署后竟然抛出了 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken 异常,经过一番搜索后弄明白了问题的产生原因及解决方法。
问题原因
Hibernate3 采用新的基于 antlr 的 HQL/SQL 查询翻译器,在 hibernate3 中需要用到 antlr,然而这个包在 weblogic 中已经包含了 antrl 类库,所以会产生一些类加载的错误,无法找到在 war 或 ear 中的 hibernate3.jar。
解决方案
方案一:修改 Hibernate 配置 hibernate.query.factory_class 设置其他查询翻译器
hibernate.query.factory_class= org.hibernate.hql.ast.ASTQueryTranslatorFactory
hibernate.query.factory_class= org.hibernate.hql.classic.ClassicQueryTranslatorFactory
方案二:修改 weblogic 的类加载顺序
- <weblogic-web-app
- xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
- http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
- <container-descriptor>
- <!--优先加载位于 Web 应用程序的 WEB-INF 目录中的类,然后再加载应用程序或系统类加载器中的类-->
- <prefer-web-inf-classes>false</prefer-web-inf-classes>
- </container-descriptor>
- </weblogic-web-app>
说明:如果刚好你的应用使用了 CXF 发布 webService,那么使用该方案后会出现 javax/xml/namespace/QName 无法识别的异常,大概错误信息如下:
- Invocation of init method failed; nested exception is java.lang.LinkageError:
- loader constraint violation: when resolving field "DATETIME" the class loader (instance of weblogic/utils/classloaders/ChangeAwareClassLoader)
- of the referring class, javax/xml/datatype/DatatypeConstants, and the class loader (instance of <bootloader>) for the field's resolved type,
- javax/xml/namespace/QName, have different Class objects for that type
该问题如何解决将在后面的方案三和方案四时提到。
方案三:设置 weblogic 的 PRE_CLASSPATH
- set PRE_CLASSPATH=F:\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar
方案四:设置 prefer-application-resources 和 prefer-application-packages
- <weblogic-web-app
- xmlns="http://xmlns.oracle.com/weblogic/weblogic-web-app"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://xmlns.oracle.com/weblogic/weblogic-web-app
- http://xmlns.oracle.com/weblogic/weblogic-web-app/1.3/weblogic-web-app.xsd">
- <container-descriptor>
- <prefer-web-inf-classes>false</prefer-web-inf-classes>
- <prefer-application-resources>
- <resource-name>META-INF/services/javax.xml.ws.spi.Provider</resource-name>
- </prefer-application-resources>
- <prefer-application-packages>
- <package-name>antlr.*</package-name>
- </prefer-application-packages>
- </container-descriptor>
- </weblogic-web-app>
附:weblogic.xml 部署描述符参考文档
http://docs.oracle.com/cd/E24329_01/web.1211/e21049/weblogic_xml.htm
http://edocs.weblogicfans.net/wls/docs92/webapp/weblogic_xml.html
参考资料:
http://guojuanjun.blog.51cto.com/277646/288121
http://tobato.iteye.com/blog/1845969
http://stackoverflow.com/questions/2702266/classnotfoundexception-hqltoken-when-running-in-weblogic
weblogic 下异常 org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken的更多相关文章
- hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
环境:weblogic10.3.5,hibernate3,GGTS(groovy/grails tools suite):出现这问题是因为该项目是从weblogic8.1.6下移植到weblogic1 ...
- weblogic中部署项目报错org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken .
原因: 原因是weblogic要查找自己的antlr,和lib下面的antlr包冲突.... 解决方法: 在weblogic.xml添加 <container-descriptor> ...
- weblogic10异常:org.hibernate.hql.ast.HqlToken
转自:http://www.programgo.com/article/68682994452/ 在做查询的时候,报出 org.hibernate.QueryException: ClassNotF ...
- WebLogic发布S2SH应用时提示ClassNotFoundException: org.hibernate.hql.ast.HqlToken异常
使用Spring+hibernate如下 <properties> <!--定义方言.fetch深度.是否显示sql--> <property name="hi ...
- 解决Eclipse编译器报错ClassNotFoundException:Org.hibernate.hql.ast.HqlToken
最近开发遇到Eclipse编译器老是报出ClassNotFoundException:Org.hibernate.hql.ast.HqlToken [from User Where id=1] 的错误 ...
- 解决org.hibernate.QueryException illegal attempt to dereference collection 异常错误
今天做项目的时候,有两个实体:款式.品牌两者关系是多对多的关联关系,实现的功能是:通过选择款式,显示出该款式的所有品牌.HQL语句如下: 运行时出现这个异常错误:org.hibernate.Query ...
- java.lang.ClassNotFoundException: org.hibernate.engine.FilterDefinition的解决方案
今天在GitHub上面看到一个有意思的项目,下载下来,使用tomcat部署失败,出现异常,网上说JDK版本太高,改低,还是失败. 由于本人有个习惯,更喜欢把项目直接放入tomcat webapps 里 ...
- org.hibernate.QueryException: could not resolve property
org.hibernate.QueryException: could not resolve property HibernateSQLXML org.hibernate.QueryExcepti ...
- J2EE 关于WebLogic下应用使用URL.openConnection获取连接返回 HttpsURLConnection与SOAPHttpsURLConnection的问题
J2EE 关于WebLogic下应用使用URL.openConnection获取连接返回 HttpsURLConnection与SOAPHttpsURLConnection的问题 2012年03月09 ...
随机推荐
- Vue报错:Uncaught TypeError: Cannot assign to read only property’exports‘ of object’#<Object>‘的解决方法
发现问题 运行一下以前的一个Vue+webpack的 vue仿新闻网站 小项目,报错 由于自己vue学习不深入,老是这个报错,找了好久(确切的说是整整一下午^...^)才找到原因 -v- Uncau ...
- openCV 备忘
yum install python-devel numpy cmake gcc gcc-c++yum install gtk2-devel libdc1394-devel libv4l-devel ...
- es6 let和const
一.let 1.let块作用域 if(true){ var a=1; let b=2; } console.log("a:"+a);//a:1 console.log(" ...
- C#使用Emit构造拦截器动态代理类
在AOP编程概念介绍中,常见的示例为拦截对象,并在对象的某方法执行前和执行后分别记录日志. 而最常用的拦截方式是使用动态代理类,用其封装一个日志拦截器,当方法被执行时进行日志记录. 日志拦截器类 1 ...
- php接收base64图片并保存
header("Content-Type: text/html; charset=utf-8"); /*print_r($_FILES)*/;//所有传入的图片都在files这个数 ...
- python函数式编程——返回函数
1.函数作为返回值 高阶函数除了可以接受函数作为参数外,还可以把函数作为结果值返回. 2.闭包 注意到返回的函数在其定义内部引用了局部变量args,所以,当一个函数返回了一个函数后,其内部的局部变量还 ...
- Codeforces 513E2 Subarray Cuts dp (看题解)
我们肯定要一大一小间隔开来所以 把式子拆出来就是类似这样的形式 s1 - 2 * s2 + 2 * s3 + ...... + sn 然后把状态开成四个, 分别表示在顶部, 在底部, 在顶部到底部的中 ...
- h5调用qq客户端
这是第一种: <a href="tencent://message/?uin=1014167202&Site=在线QQ&Menu=yes"> <i ...
- Linux下java开发环境配置总结
1 安装JDK,卸载以前的jdk,安装jdk1.8 : 参考:http://www.jb51.net/os/RedHat/73016.html 需要注意配置环境变量中的路径要和当前安装的jdk路径一致 ...
- 爬虫3 requests之json 把json数据转化为字典
#json 将json数据转化为字典,方便操作数据 res = requests.get('http://httpbin.org/get') print(res.json()) #res.json() ...