-->
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.  [ 13 posts ] 
Author Message
 Post subject: Error using named query: ClassCastException
PostPosted: Mon Feb 14, 2005 10:59 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Hi all,
I've found an error using named queries with hibernate 3 beta 4 (CVS today checkout).
I've tracked down the problem to the class org.hibernate.hql.ast.SyntheticAndFactory(line 44):
Code:
                fragment = ( SqlFragment ) ASTUtil.create( astFactory, SQL_TOKEN, whereFragment );


but the method returns AST object (org.hibernate.hql.ast.ASTUtil:34):
Code:
        public static AST create(ASTFactory astFactory, int type, String text) {
                AST node = astFactory.create( type, text );
                return node;
        }


The error occurs during initialization, when hibernate checks for named queries correctness.

Here's full stack trace:
Code:
15:25:12,833  INFO SessionFactoryImpl:365 - Checking 4 named queries
15:25:14,351 ERROR PersistenceManagerFactory:38 - error configuring
java.lang.ClassCastException
        at org.hibernate.hql.ast.SyntheticAndFactory.addWhereFragment(SyntheticAndFactory.java:44)
        at org.hibernate.hql.ast.JoinProcessor.addJoinNodes(JoinProcessor.java:98)
        at org.hibernate.hql.ast.JoinProcessor.processJoins(JoinProcessor.java:70)
        at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:354)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.afterQuery(HqlSqlBaseWalker.java:112)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:296)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.select(HqlSqlBaseWalker.java:132)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:202)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:413)
        at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:374)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:277)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1033)
...

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 11:04 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Please report this in JIRA, with the actual named query that failed compilation.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 11:23 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
This error seems unrelated to a specific query. Changing the hql parser from ast to classic solves the problem.

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 11:31 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Issue created: http://opensource.atlassian.com/projects/hibernate/browse/HHH-140

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 12:41 pm 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
More on this:
the problem is not what I've reported, since SqlFragment extends AST.
I've rechecked all the libraries I'm using, but the problem still occurs.

I'll add some info:

Hibernate init log:
Code:
17:14:35,482  INFO Configuration:1218 - configuring from resource: /hibernate.cfg.xml
17:14:35,484  INFO Configuration:1189 - Configuration resource: /hibernate.cfg.xml
17:14:35,495  INFO Configuration:438 - Mapping resource: /web/model/Categoria.hbm.xml
17:14:35,522  INFO HbmBinder:267 - Mapping class: web.model.Categoria -> CATEGORIA
17:14:35,525  INFO Configuration:438 - Mapping resource: web/model/Genere.hbm.xml
17:14:35,550  INFO HbmBinder:267 - Mapping class: web.model.Genere -> GENERE
17:14:35,552  INFO Configuration:438 - Mapping resource: web/model/Articolo.hbm.xml
17:14:35,584  INFO HbmBinder:267 - Mapping class: web.model.Articolo -> ARTICOLO
17:14:35,589  INFO Configuration:438 - Mapping resource: web/model/Autore.hbm.xml
17:14:35,640  INFO HbmBinder:267 - Mapping class: web.model.Autore -> AUTORE
17:14:35,646  INFO Configuration:438 - Mapping resource: web/model/Order.hbm.xml
17:14:35,695  INFO HbmBinder:267 - Mapping class: web.model.Order -> WEBORDER
17:14:35,701  INFO Configuration:438 - Mapping resource: web/model/OrderItem.hbm.xml
17:14:35,729  INFO HbmBinder:267 - Mapping class: web.model.OrderItem -> WEBORDERITEM
17:14:35,732  INFO Configuration:1330 - Configured SessionFactory: null
17:14:35,735  INFO Configuration:834 - processing extends queue
17:14:35,736  INFO Configuration:838 - processing collection mappings
17:14:35,737  INFO HbmBinder:2028 - Mapping collection: web.model.Categoria.sottocategoriaList -> CATEGORIA
17:14:35,738  INFO HbmBinder:2028 - Mapping collection: web.model.Categoria.genereList -> GENERE
17:14:35,740  INFO HbmBinder:2028 - Mapping collection: web.model.Genere.articoloList -> ARTICOLO
17:14:35,741  INFO HbmBinder:2028 - Mapping collection: web.model.Autore.articoloList -> ARTICOLO
17:14:35,743  INFO HbmBinder:2028 - Mapping collection: web.model.Order.orderitemList -> WEBORDERITEM
17:14:35,744  INFO Configuration:847 - processing association property references
17:14:35,746  INFO Configuration:874 - processing foreign key constraints
17:14:35,749  INFO Dialect:89 - Using dialect: org.hibernate.dialect.OracleDialect
17:14:35,751  INFO SettingsFactory:87 - Maximum outer join fetch depth: 1
17:14:35,752  INFO SettingsFactory:90 - Default batch fetch size: 1
17:14:35,754  INFO SettingsFactory:94 - Generate SQL with comments: disabled
17:14:35,756  INFO SettingsFactory:98 - Order SQL updates by primary key: disabled
17:14:35,759  INFO SettingsFactory:272 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
17:14:35,761  INFO SettingsFactory:106 - Query language substitutions: {no='N', true=1, yes='Y', false=0}
17:14:35,762  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
17:14:35,764  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 5
17:14:35,765  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
17:14:35,766  INFO DriverManagerConnectionProvider:80 - using driver: oracle.jdbc.driver.OracleDriver at URL: jdbc:oracle:thin:@localhost:***:***
17:14:35,768  INFO DriverManagerConnectionProvider:83 - connection properties: {user=***, password=***, fixedString=true
}
17:14:35,769 DEBUG DriverManagerConnectionProvider:93 - total checked-out connections: 0
17:14:35,770 DEBUG DriverManagerConnectionProvider:109 - opening new JDBC connection
17:14:35,846 DEBUG DriverManagerConnectionProvider:115 - created connection to: jdbc:oracle:thin:@localhost:***:***, Isolation Level
: 2
17:14:35,848 DEBUG DriverManagerConnectionProvider:129 - returning connection to pool, pool size: 1
17:14:35,849  INFO SettingsFactory:155 - Scrollable result sets: enabled
17:14:35,850  INFO SettingsFactory:163 - JDBC3 getGeneratedKeys(): disabled
17:14:35,851  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
17:14:35,853  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write
or transactional second-level cache is not recommended)
17:14:35,854  INFO SettingsFactory:175 - Automatic flush during beforeCompletion(): disabled
17:14:35,855  INFO SettingsFactory:178 - Automatic session close at end of transaction: disabled
17:14:35,856  INFO SettingsFactory:259 - Cache provider: org.hibernate.cache.EhCacheProvider
17:14:35,858  INFO SettingsFactory:186 - Second-level cache: enabled
17:14:35,859  INFO SettingsFactory:191 - Optimize cache for minimal puts: disabled
17:14:35,860  INFO SettingsFactory:198 - Structured second-level cache entries: enabled
17:14:35,861  INFO SettingsFactory:202 - Query cache: disabled
17:14:35,862  INFO SettingsFactory:209 - Echoing all SQL to stdout
17:14:35,863  INFO SettingsFactory:213 - Statistics: disabled
17:14:35,865  INFO SettingsFactory:217 - Deleted entity synthetic identifier rollback: disabled
17:14:35,866  INFO SettingsFactory:231 - Default entity-mode: pojo
17:14:35,867  INFO SessionFactoryImpl:139 - building session factory
17:14:36,057  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured
17:14:36,059  INFO SessionFactoryImpl:365 - Checking 4 named queries
17:14:36,165 ERROR PersistenceManagerFactory:38 - error configuring


Additional stack trace:
Code:
java.lang.ClassCastException
        at org.hibernate.hql.ast.SyntheticAndFactory.addWhereFragment(SyntheticAndFactory.java:44)
        at org.hibernate.hql.ast.JoinProcessor.addJoinNodes(JoinProcessor.java:98)
        at org.hibernate.hql.ast.JoinProcessor.processJoins(JoinProcessor.java:70)
        at org.hibernate.hql.ast.HqlSqlWalker.processQuery(HqlSqlWalker.java:354)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.afterQuery(HqlSqlBaseWalker.java:112)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.query(HqlSqlBaseWalker.java:296)
        at org.hibernate.hql.antlr.HqlSqlBaseWalker.select(HqlSqlBaseWalker.java:132)
        at org.hibernate.hql.ast.QueryTranslatorImpl.analyze(QueryTranslatorImpl.java:202)
        at org.hibernate.hql.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:158)
        at org.hibernate.hql.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:111)
        at org.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:413)
        at org.hibernate.impl.SessionFactoryImpl.checkNamedQueries(SessionFactoryImpl.java:374)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:277)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1033)
...


17:14:36,169 DEBUG DefaultComponentManager:145 - Error loading or setting up resource: java.util.HashMap
java.lang.RuntimeException
        at web.component.PersistenceManagerFactory.init(PersistenceManagerFactory.java:39)
        at com.opensymphony.xwork.interceptor.component.DefaultComponentManager.loadResource(DefaultComponentManager.java:154)
        at com.opensymphony.xwork.interceptor.component.DefaultComponentManager.loadResource(DefaultComponentManager.java:139)
        at com.opensymphony.xwork.interceptor.component.DefaultComponentManager.loadResource(DefaultComponentManager.java:139)
        at com.opensymphony.xwork.interceptor.component.DefaultComponentManager.initializeObject(DefaultComponentManager.java:75)
        at com.opensymphony.xwork.interceptor.component.ComponentInterceptor.before(ComponentInterceptor.java:29)
        at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:34)
        at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:166)
        at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:115)
        at com.opensymphony.webwork.dispatcher.ServletDispatcher.serviceAction(ServletDispatcher.java:278)
        at com.opensymphony.webwork.dispatcher.ServletDispatcher.service(ServletDispatcher.java:248)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:336)


_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Do you have some other antlr versions or something on your classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 1:20 pm 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Nope.
Here's the complete list of jar used in the WEB-INF/lib dir.

Code:
ant-antlr-1.6.2.jar
dom4j-1.5.2.jar
jython.jar
velocity-dep.jar
antlr-2.7.4.jar
ehcache-1.1.jar
odmg-3.0.jar
velocity-tools-view-1.1.jar
cglib-full-2.0.2.jar
freemarker-2.3pre13.jar
ognl-2.6.5.jar
webmacro.jar
oscore.jar
webwork-2.1.jar
commons-collections-2.1.1.jar
hibernate3-cvs.jar
osuser-config.jar
xerces-2.6.2.jar
commons-fileupload.jar
jakarta-oro.jar
osuser.jar
xml-apis.jar
commons-lang.jar
jasperreports-0.5.0.jar
pell-multipart.jar  xwork-1.0.1.jar
commons-logging-1.0.4.jar
jaxen-1.1-beta-4.jar
proxool-0.8.3.jar
cos-multipart.jar
jfreechart-0.9.13.jar
radeox.jar

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 1:23 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Check that the antlr jar does not come from somewhere else (server dependencies or so)


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 1:50 pm 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
The antlr jar I'm using is the one present in hibernate-3.0/lib dir.
I've checked all the jars in the application ear and in the app server lib dir. the 2.7.4 seems to be the only jar referenced.
Any idea?

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 14, 2005 2:40 pm 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
I'll have a look at it, it might not be a classpath issue.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 8:41 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
I'm using the CVS version of hibernate(02/15), built with included build.sh script. I've checked all the jar included in the project, but antlr-2.7.4.jar is the only one with classes of antlr package.
Could it be a conflict with other libraries that use antlr compiled with a different version ?

_________________
--
Marco


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 15, 2005 9:14 am 
Contributor
Contributor

Joined: Thu Nov 06, 2003 9:49 pm
Posts: 104
Location: New York, NY
It could be that you have a different version of ANTLR around at runtime. Maybe you have an older version of Hibernate3 in your classpath?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 16, 2005 6:37 am 
Regular
Regular

Joined: Fri Sep 17, 2004 10:51 am
Posts: 61
Location: Rimini, Italy
Nope. It could be a conflict with other libraries. I'll build a sample webapp that uses hibernate3, webwork & velocity, and try to deploy to a different server, and I'll let you know the results.

_________________
--
Marco


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 13 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.