Reputation: 107
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;
}
Exception stacktrace:
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
Upvotes: 1
Views: 9170
Reputation: 7
Copying the antlr.2.7.6.jar into Web Logic Lib directory and setting the PRE_CLASSPATH to this jar file worked for me. The weblogic server starts earlier than the custom application you are working on. So setting it's pre_classpath in the common environment will load the classes and you won't get that ClassNotFoundException exception. Note I am using Windows.
@the weblogic lib directory is loacated in <WL_HOME>\common\lib\
@Modify commEnv.cmd or commEnv.sh located in <WL_HOME>\common\bin\ as follows
@after WL_HOME (Web Logic Server Home Directory) has been set ...
@rem Set WebLogic Home
set WL_HOME=E:\Oracle\Middleware\wlserver_10.3
@set the pre_classpath
set PRE_CLASSPATH=%WL_HOME%\lib\antlr.jar
set CLASSPATH=%PRE_CLASSPATH%;%CLASSPATH%
Upvotes: 0
Reputation: 1
The package name 'rescuetrailer' is already been used by another package: {PackageConfig Name:rescuetrailer namespace: abstract:false parents:[{PackageConfig Name:webwork-default namespace: abstract:false parents:[]}]}
Could not execute action
org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from pinacle.person.model.Person p where p.jobNo='meiql']
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)
at antlr.CharScanner.<init>(CharScanner.java:51)
at antlr.CharScanner.<init>(CharScanner.java:60)
at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:56)
at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:53)
at org.hibernate.hql.antlr.HqlBaseLexer.<init>(HqlBaseLexer.java:50)
at org.hibernate.hql.ast.HqlLexer.<init>(HqlLexer.java:26)
at org.hibernate.hql.ast.HqlParser.getInstance(HqlParser.java:44)
weblogic 10.3.6 jdk 1.6 centos7.6
just do this
cat $DOMAIN_HOME/bin/setDomainEnv.sh | grep PRE_CLASSPATH
export PRE_CLASSPATH=/YOUDIR/antlr-2.7.6.jar
Upvotes: 0
Reputation: 107
I resolved this issue. Currently I am using weblogic 12c and Hibernate 3.6.9.
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.
<WL_HOME>/common/lib/antlr-2.7.7.jar
For Windows:
Add the below line in /common/bin/commEnv.cmd
set PRE_CLASSPATH=%WL_HOME%/common/lib/antlr-2.7.7.jar
For Linux:
Add the below lines in /common/bin/commEnv.sh
<WL_HOME>/PRE_CLASSPATH=$WL_HOME/common/lib/antlr-2.7.7.jar
Export PRE_CLASSPATH
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.
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.
Upvotes: 1
Reputation: 21
I faced this issue in weblogic 10.3, having antlr-2.7.7.jar in the application classpath and was able to resolve it by adding a prefer-application-packages of "antlr.*" in the file weblogic-application.xml.
Upvotes: 2
Reputation: 381
You can also modify the weblogic.xml file to prefer-application-packages. Check out this forum post for the details.
Upvotes: 0
Reputation: 31
Depending on your exact hibernate needs, it may be possible to remove the antlr dependency entirely. By adding this to your hibernate properties you may be able to run without issue:
<property name="hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>
Upvotes: 3