留言板

instanceable=false result in "HqlToken cannot be cast to antlr.Token"?

thumbnail
Amigoo Earth,修改在11 年前。

instanceable=false result in "HqlToken cannot be cast to antlr.Token"?

New Member 帖子: 8 加入日期: 12-10-15 最近的帖子
Long time no see, everybody… Hope everyone is all right in the cold winter day. :-)

This is our scenario.
Suppose, there is a portlet named ppp. (Liferay CE 6.0.6, Hibernate 3.6.10.Final for ppp project.)
1. The original “instanceable” property is set to “true”. (As you know, in liferay-portlet.xml)
2. Deploy ppp to a new created Page. And everything work fine at this time.
3. Change “instanceable” property of ppp to “false”.
4. Open the page containing ppp again and we got an error box.

The Exception in the backend as bellow:
14:37:59,173 ERROR [jsp:154] java.lang.ClassCastException: org.hibernate.hql.ast.HqlToken cannot be cast to antlr.Token
at antlr.CharScanner.makeToken(CharScanner.java:173)
at org.hibernate.hql.ast.HqlLexer.makeToken(HqlLexer.java:62)
at org.hibernate.hql.antlr.HqlBaseLexer.mIDENT(HqlBaseLexer.java:599)
at org.hibernate.hql.antlr.HqlBaseLexer.nextToken(HqlBaseLexer.java:270)
at antlr.TokenBuffer.fill(TokenBuffer.java:69)
at antlr.TokenBuffer.LA(TokenBuffer.java:80)
at antlr.LLkParser.LA(LLkParser.java:52)
at org.hibernate.hql.antlr.HqlBaseParser.statement(HqlBaseParser.java:141)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:276)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:184)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:138)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:101)
at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:80)
at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:124)
at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:156)
at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:135)
at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1770)
at com.foo.module.base.dao.RelationDAOImpl.findRelation(RelationDAOImpl.java:50)
at com.foo.module.base.service.RelationServiceImpl.findRelation(RelationServiceImpl.java:51)
at com.foo.module.base.util.RelationServiceUtil.findRelation(RelationServiceUtil.java:74)

5. If we delete the page containing ppp and repeat the step 2, it will become OK magically.

But we are confused, and any google is no help. Someone refer to antlr.jar shipped with JBoss and Weblogic should result in it, but our app server is Tomcat, and in the tomcat’s classpath, there is no antlr.jar loaded. Someone mentioned that add this property to Hibernate should resolve the problem.
hibernate.query.factory_class=org.hibernate.hql.classic.ClassicQueryTranslatorFactory
Yes, it really work, but ClassicQueryTranslatorFactory did not meet our requirement.

Any suggestion is appreciated. Thanks.
Schmock Orock Orockski,修改在11 年前。

RE: instanceable=false result in "HqlToken cannot be cast to antlr.Token"?

New Member 帖子: 8 加入日期: 09-8-20 最近的帖子
Hey, this solved our problem:

Set the following java system property on tomcat startup:

ANTLR_USE_DIRECT_CLASS_LOADING=true
thumbnail
Amigoo Earth,修改在11 年前。

RE: instanceable=false result in "HqlToken cannot be cast to antlr.Token"?

New Member 帖子: 8 加入日期: 12-10-15 最近的帖子
Schmock Orock Orockski:
Hey, this solved our problem:

Set the following java system property on tomcat startup:

ANTLR_USE_DIRECT_CLASS_LOADING=true



Thank you very much, Schmock!
It works in our environment, too.
Is there any side effect already known? For I'm not good at antlr yet... :-)