ClassNotFoundException:每当我尝试执行HQL时,org.hibernate.hql.ast.HqlToken [英] ClassNotFoundException: org.hibernate.hql.ast.HqlToken when ever I am trying to execute HQL

查看:111
本文介绍了ClassNotFoundException:每当我尝试执行HQL时,org.hibernate.hql.ast.HqlToken的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试在代码中执行HQL时,发生以下异常.我在各个站点进行了检查,发现antlr.2.7.6.jar shd位于类路径中.我在项目中检查了一下,发现这在我的Maven依赖项中.因此,不应有任何此类问题.但是我仍然遇到这个问题.谁能在这方面帮助我.我在"empList = getHibernateTemplate().find(来自Employee");行中收到此错误.在以下功能中.

The following exception is occurring when I try to execute HQL in my code. I checked this in various sites and found that antlr.2.7.6.jar shd be in class path. I checked this in my project and found that this is there in my Maven dependencies. So there should not be any such issue. But still I am getting this issue. Can anyone help me in this regard. I am getting this error in line "empList = getHibernateTemplate().find("from Employee");" in the following function.

public List<EmployeeTO> getAllEmp() {
    List<Employee> empList =  new ArrayList<Employee>();
List<EmployeeTO> empListTO =  new ArrayList<EmployeeTO>();
empList = getHibernateTemplate().find("from Employee");
try {
    BeanUtils.copyProperties(empListTO, empList);
} catch (IllegalAccessException e) {
    e.printStackTrace();
} catch (InvocationTargetException e) {
    e.printStackTrace();
}
    return empListTO;
}

异常堆栈跟踪:

Root cause of ServletException.
     org.springframework.orm.hibernate3.HibernateQueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.myapp.domain.Employee]; nested exception is org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.myapp.domain.Employee]
    at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:656)
    at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:412)
    at org.springframework.orm.hibernate3.HibernateTemplate.doExecute(HibernateTemplate.java:411)
    at org.springframework.orm.hibernate3.HibernateTemplate.executeWithNativeSession(HibernateTemplate.java:374)
    at org.springframework.orm.hibernate3.HibernateTemplate.find(HibernateTemplate.java:912)
    Truncated. see log file for complete stacktrace
Caused By: org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.myapp.domain.Employee]
    at org.hibernate.hql.ast.HqlLexer.panic(HqlLexer.java:80)
    at antlr.CharScanner.setTokenObjectClass(CharScanner.java:340)
    at org.hibernate.hql.ast.HqlLexer.setTokenObjectClass(HqlLexer.java:54)
    at antlr.CharScanner.<init>(CharScanner.java:51)
    at antlr.CharScanner.<init>(CharScanner.java:60)
    Truncated. see log file for complete stacktrace

推荐答案

我解决了此问题.目前,我正在使用weblogic 12c和Hibernate 3.6.9.

I resolved this issue. Currently I am using weblogic 12c and Hibernate 3.6.9.

在一个站点中,我发现我们需要在weblogic pre_compile路径变量中添加antlr.2.7.6.jar文件.

And in one of the site I found that we need to add antlr.2.7.6.jar file in weblogic pre_compile path variable.

  1. Weblogic 12c:对于符合Java EE 6的Weblogic版本,我们只需要添加antlr jar依赖项即可.
  2. 下载以下文件并将其放在<WL_HOME>/common/lib/antlr-2.7.7.jar
  3. 将以上文件添加到类路径中
  1. Weblogic 12c: For Weblogic versions which are Java EE 6 compliant, we need to add only antlr jar dependency.
  2. Download and place the below files under <WL_HOME>/common/lib/antlr-2.7.7.jar
  3. Add the above files in classpath

对于Windows:

/common/bin/commEnv.cmd

set PRE_CLASSPATH=%WL_HOME%/common/lib/antlr-2.7.7.jar

对于Linux:

/common/bin/commEnv.sh

<WL_HOME>/PRE_CLASSPATH=$WL_HOME/common/lib/antlr-2.7.7.jar

导出PRE_CLASSPATH

我在窗户机器上遵循了以下步骤.对于我来说, wl_home common/lib 中设置为C:\Oracle\Middleware\wlserver_12.1v.

I followed these steps on my window machine. For my case wl_home was set to C:\Oracle\Middleware\wlserver_12.1v here within common/lib.

我添加了这个jar,并在/common/bin/commEnv.cmd 中添加了集PRE_CLASSPATH=%WL_HOME%/common/lib/antlr-2.7.7.jar代码,然后重新启动了weblogic.这对我来说很好.

I added this jar and added set PRE_CLASSPATH=%WL_HOME%/common/lib/antlr-2.7.7.jar code in /common/bin/commEnv.cmd and restarted weblogic. This worked fine for me.

这篇关于ClassNotFoundException:每当我尝试执行HQL时,org.hibernate.hql.ast.HqlToken的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆