-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: ClassNotFoundException: org.hibernate.hql.ast.HqlToken
PostPosted: Thu Dec 15, 2005 5:33 am 
Newbie

Joined: Thu Dec 15, 2005 5:20 am
Posts: 1
Hi All
I am playing around with hibernate 3.1 rc1 I am trying to list all I have a test schema in oracle comprising of employee & deparment table

I am trying to list all the departments in deparment table using following code snipet

I am deploying same on weblogic server 8.1 sp4.I tried searching on net got following link that says ANTLR used by weblogic needs to replaced by the ANTLR ships along with hibernate. Tried using the ANTLR that comes along with hibernate but .....

public List findAllDepts()
{
System.out.println("findAllDepts----------->1");
SessionManager sessionManager = SessionManager.getInstance();
System.out.println("findAllDepts----------->2");
Session session = sessionManager.getSession();
Transaction tx = session.beginTransaction();
Query query = sessionManager.getQuery("from Department as dept");
List list = query.list();
tx.commit();
System.out.println("findAllDepts----------->2"+list);
return list;
}

I am getting following error:

org.hibernate.QueryException: ClassNotFoundException: org.hibernate.hql.ast.HqlToken [from com.test.orm.Department as dept]
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)
at org.hibernate.hql.ast.QueryTranslatorImpl.parse(QueryTranslatorImpl.java:228)
at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:151)
at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:101)
at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:473)
at org.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1032)
at org.hibernate.impl.SessionImpl.list(SessionImpl.java:982)
at org.hibernate.impl.QueryImpl.list(QueryImpl.java:74)
at com.test.orm.EmployeeManager.findAllDepts(Unknown Source)
at jsp_servlet._jsps.__create._jspService(__create.java:142)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:33)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:1006)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:419)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:463)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:315)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6718)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:121)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3764)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2644)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:219)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:178)

Any Ideas

Thanks & Regards
Amit


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 15, 2005 5:59 am 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
FAQ


Top
 Profile  
 
 Post subject: This worked for me
PostPosted: Mon Mar 19, 2007 8:16 am 
Newbie

Joined: Mon Mar 19, 2007 7:34 am
Posts: 1
I had a similar problem, but it only showed when using a HibernateCallback. Straight calls to the HibernateTemplate were fine.

Closest I could find in the FAQ was this:
http://www.hibernate.org/116.html#A2

If Christian knows there's something better than this then why not post the link?

What I found fixed the problem was the following:

Using Hibernate3.2 with WebLogic 8.1.4 I needed to add the antlr-2.7.6.jar from the hibernate distribution lib directory to WEB-INF/lib, then add a weblogic.xml containing:

<prefer-web-inf-classes>true</prefer-web-inf-classes>

to force classloading from the web app first.


Top
 Profile  
 
 Post subject: Fix for Oracle OC4J/AS 10.1.3
PostPosted: Fri Mar 30, 2007 6:19 am 
Newbie

Joined: Fri Mar 30, 2007 5:57 am
Posts: 5
I had the same problem when deploying to OC4J 10.1.3. It looks like the antlr.jar which is distributed with Oracle Toplink was being loaded before the one in /WEB-INF/lib

There are two possible solutions to this:

Add the follow entry into the root of your orion-application.xml file in your EAR which tells OC4J not to load the Toplink libraries.
Code:
<imported-shared-libraries>
  <remove-inherited name="oracle.toplink"/>
</imported-shared-libraries>

Or

Add the follow entry into the root of your orion-web.xml in your WAR
Code:
<web-app-class-loader search-local-classes-first="true"  include-war-manifest-class-path="true" />


The latter solution didn't work immediately for me because the SAX parser my app was different to the one on the app server but it may be useful for others.

Also note that the settings above can also be configured at deploy time when deploying with Oracle Enterprise Manager.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.