-->
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.  [ 3 posts ] 
Author Message
 Post subject: [solved] Problem with createQuery in the reference tutorial
PostPosted: Sun May 28, 2006 11:49 am 
Newbie

Joined: Sun May 28, 2006 10:10 am
Posts: 2
Hi guys,

I'm new to hibernate so i started to follow the instructions in the reference tutorial on http://www.hibernate.org/hib_docs/v3/re ... orial.html. Instead of HSQLDB I'm using MySQL 5.0 with Hibernate 3.1.3.

Up to section 1.2.6 everything just works fine. The database tables are generated automatically and the event objects get stored well. But when I'm trying to execute

Code:
List result = session.createQuery("from Event").list();

I'm getting an UndeclaredThrowableException.

Here's the console output
Code:
16:37:30,826  INFO Environment:479 - Hibernate 3.1.3
16:37:30,836  INFO Environment:509 - hibernate.properties not found
16:37:30,836  INFO Environment:525 - using CGLIB reflection optimizer
16:37:30,836  INFO Environment:555 - using JDK 1.4 java.sql.Timestamp handling
16:37:30,916  INFO Configuration:1308 - configuring from resource: /hibernate.cfg.xml
16:37:30,916  INFO Configuration:1285 - Configuration resource: /hibernate.cfg.xml
16:37:31,016  INFO Configuration:469 - Reading mappings from resource: events/Event.hbm.xml
16:37:31,136  INFO HbmBinder:309 - Mapping class: events.Event -> EVENTS
16:37:31,166  INFO Configuration:1419 - Configured SessionFactory: null
16:37:31,236  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
16:37:31,236  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 5
16:37:31,236  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
16:37:31,236  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://127.0.0.1:3306/hibernate3
Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
   at $Proxy0.createQuery(Unknown Source)
   at events.EventManager.listEvents(EventManager.java:51)
   at events.EventManager.main(EventManager.java:23)
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
   at java.lang.reflect.Method.invoke(Unknown Source)
   at org.hibernate.context.ThreadLocalSessionContext$TransactionProtectionWrapper.invoke(ThreadLocalSessionContext.java:301)
   ... 3 more
Caused by: java.lang.NoClassDefFoundError: antlr/ANTLRException
   at org.hibernate.hql.ast.ASTQueryTranslatorFactory.createQueryTranslator(ASTQueryTranslatorFactory.java:35)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:72)
   at org.hibernate.engine.query.HQLQueryPlan.<init>(HQLQueryPlan.java:54)
   at org.hibernate.engine.query.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:71)
   at org.hibernate.impl.AbstractSessionImpl.getHQLQueryPlan(AbstractSessionImpl.java:133)
   at org.hibernate.impl.AbstractSessionImpl.createQuery(AbstractSessionImpl.java:112)
   at org.hibernate.impl.SessionImpl.createQuery(SessionImpl.java:1583)
   ... 8 more
16:37:31,256  INFO DriverManagerConnectionProvider:86 - connection properties: {user=hibernate, password=****}
16:37:31,537  INFO SettingsFactory:77 - RDBMS: MySQL, version: 5.0.20-community
16:37:31,537  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.12 ( $Date: 2005-11-17 15:53:48 +0100 (Thu, 17 Nov 2005) $, $Revision$ )
16:37:31,557  INFO Dialect:103 - Using dialect: org.hibernate.dialect.MySQLDialect
16:37:31,577  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
16:37:31,577  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
16:37:31,577  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
16:37:31,577  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
16:37:31,577  INFO SettingsFactory:136 - JDBC batch size: 15
16:37:31,577  INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
16:37:31,577  INFO SettingsFactory:144 - Scrollable result sets: enabled
16:37:31,577  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
16:37:31,577  INFO SettingsFactory:160 - Connection release mode: auto
16:37:31,587  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
16:37:31,587  INFO SettingsFactory:187 - Default batch fetch size: 1
16:37:31,587  INFO SettingsFactory:191 - Generate SQL with comments: disabled
16:37:31,587  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
16:37:31,587  INFO SettingsFactory:338 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
16:37:31,587  INFO ASTQueryTranslatorFactory:24 - Using ASTQueryTranslatorFactory
16:37:31,587  INFO SettingsFactory:203 - Query language substitutions: {}
16:37:31,587  INFO SettingsFactory:209 - Second-level cache: enabled
16:37:31,587  INFO SettingsFactory:213 - Query cache: disabled
16:37:31,587  INFO SettingsFactory:325 - Cache provider: org.hibernate.cache.NoCacheProvider
16:37:31,587  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
16:37:31,587  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
16:37:31,597  INFO SettingsFactory:257 - Echoing all SQL to stdout
16:37:31,597  INFO SettingsFactory:264 - Statistics: disabled
16:37:31,597  INFO SettingsFactory:268 - Deleted entity synthetic identifier rollback: disabled
16:37:31,597  INFO SettingsFactory:283 - Default entity-mode: pojo
16:37:31,627  INFO SessionFactoryImpl:154 - building session factory
16:37:31,947  INFO SessionFactoryObjectFactory:82 - Not binding factory to JNDI, no JNDI name configured


I searched the forum and the documentation for some articles referring to this exception but i didn't find any posts. Could someone help me please, I have no idea what I'm doing wrong :/

If you need more files (hibernate.cfg.xml or Event.hbm.xml) please let me know.

Greets & thx in advance
frieder


Last edited by frieder on Mon May 29, 2006 5:00 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 4:15 pm 
Newbie

Joined: Sun May 28, 2006 4:07 pm
Posts: 1
Hi Frieder,

I encountered exact the same problem with the same version of mysql. After plugging in hsqldb the problem persisted .. so the problem wasn't mysql related. As a last resort I decided to copy all hibernate libraries into my project... and it worked!

I have yet to find out what library was actually missing, but at least I can continue the tutorial.

regards,

Robert


Top
 Profile  
 
 Post subject:
PostPosted: Sun May 28, 2006 4:42 pm 
Newbie

Joined: Sun May 28, 2006 10:10 am
Posts: 2
Hi Robert,

big thanks for your advice, now everything works fine ;)

I tried to add all libs and then removed the libs one by one. In my case tThe needed lib was antlr.jar (btw ant-antlr.jar isn't needed).

Thx & regards
Frieder


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