当我尝试在我的代码中执行 HQL 时发生以下异常。我在各个站点中检查了这一点,发现 antlr.2.7.6.jar shd 在类路径中。我在我的项目中检查了这个,发现它在我的 Maven 依赖项中。所以不应该有这样的问题。但我仍然遇到这个问题。任何人都可以在这方面帮助我。我在 "empList = getHibernateTemplate().find("from Employee");" 行中收到此错误 在下面的函数中。
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