-->
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.  [ 5 posts ] 
Author Message
 Post subject: Problem with my first application
PostPosted: Tue Apr 11, 2006 6:11 pm 
Newbie

Joined: Tue Apr 11, 2006 5:08 pm
Posts: 4
Sorry, I tried don't send a fool question to this forum but i can't find a solution for my problem. Please, someone help me.

Hibernate version:
2.1.7

Mapping documents:
Code:
<?xml version="1.0"?>

<!DOCTYPE hibernate-mapping PUBLIC
   "-//Hibernate/Hibernate Mapping DTD 2.0//EN"
   "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping>
   <class
      name="hello.Message"
      table="Message">
      <id   
         name="id"
         column="message_id"
         type="long">
         <generator class="native"/>
      </id>
      <property
         name="text"
         column="message_text"/>
      <many-to-one
         name="nextMessage"
         cascade="all"
         column="next_message_id"/>
   </class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
Code:
         Configuration cfg = new Configuration();
         cfg.addResource("hello/Message.hbm.xml");
         cfg.setProperties(System.getProperties());
         SessionFactory sessions = cfg.buildSessionFactory();
         
         Session session = sessions.openSession(); //getSessionFactory().openSession();
         Transaction tx = session.beginTransaction();
         Message message = new Message("Hello world");
         session.save(message);
         tx.commit();
         session.close();


Full stack trace of any exception that occurs:
Code:
2006-04-11 17:08:18,546 INFO  hibernate.cfg.Environment  -> Hibernate 2.1.8
2006-04-11 17:08:18,556 INFO  hibernate.cfg.Environment  -> loaded properties from resource hibernate.properties: {hibernate.c3p0.timeout=300, hibernate.connection.driver_class=org.gjt.mm.mysql.Driver, hibernate.cglib.use_reflection_optimizer=true, hibernate.c3p0.max_statements=50, hibernate.c3p0.max_size=30, hibernate.dialect=net.sf.hibernate.dialect.MySQLDialect, hibernate.c3p0.idle_test_period=3000, hibernate.c3p0.min_size=5, hibernate.connection.username=root, hibernate.connection.url=jdbc:mysql://192.168.10.100:3306/temp, hibernate.connection.password=root}
2006-04-11 17:08:18,558 INFO  hibernate.cfg.Environment  -> using CGLIB reflection optimizer
2006-04-11 17:08:18,562 INFO  hibernate.cfg.Environment  -> using JDK 1.4 java.sql.Timestamp handling
2006-04-11 17:08:18,565 INFO  hibernate.cfg.Configuration  -> Mapping resource: hello/Message.hbm.xml
2006-04-11 17:08:18,827 DEBUG hibernate.util.DTDEntityResolver  -> trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
2006-04-11 17:08:18,831 DEBUG hibernate.util.DTDEntityResolver  -> http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtdnot found in classpath
2006-04-11 17:08:20,766 INFO  hibernate.cfg.Binder  -> Mapping class: hello.Message -> Message
2006-04-11 17:08:20,811 DEBUG hibernate.cfg.Binder  -> Mapped property: id -> message_id, type: long
2006-04-11 17:08:20,818 DEBUG hibernate.cfg.Binder  -> Mapped property: text -> message_text, type: string
2006-04-11 17:08:20,822 DEBUG hibernate.cfg.Binder  -> Mapped property: nextMessage -> next_message_id, type: hello.Message
2006-04-11 17:08:20,823 INFO  hibernate.cfg.Configuration  -> processing one-to-many association mappings
2006-04-11 17:08:20,824 INFO  hibernate.cfg.Configuration  -> processing one-to-one association property references
2006-04-11 17:08:20,824 INFO  hibernate.cfg.Configuration  -> processing foreign key constraints
2006-04-11 17:08:20,825 DEBUG hibernate.cfg.Configuration  -> resolving reference to class: hello.Message
2006-04-11 17:08:20,837 INFO  hibernate.dialect.Dialect  -> Using dialect: net.sf.hibernate.dialect.MySQLDialect
2006-04-11 17:08:20,859 DEBUG hibernate.exception.SQLExceptionConverterFactory  -> Using dialect defined converter
2006-04-11 17:08:20,861 INFO  hibernate.cfg.SettingsFactory  -> Maximim outer join fetch depth: 2
2006-04-11 17:08:20,862 INFO  hibernate.cfg.SettingsFactory  -> Use outer join fetching: true
2006-04-11 17:08:20,871 WARN  hibernate.connection.UserSuppliedConnectionProvider  -> No connection properties specified - the user must supply JDBC connections
2006-04-11 17:08:20,886 INFO  hibernate.transaction.TransactionManagerLookupFactory  -> No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
2006-04-11 17:08:20,893 INFO  hibernate.cfg.SettingsFactory  -> Use scrollable result sets: false
2006-04-11 17:08:20,894 INFO  hibernate.cfg.SettingsFactory  -> Use JDBC3 getGeneratedKeys(): false
2006-04-11 17:08:20,895 INFO  hibernate.cfg.SettingsFactory  -> Optimize cache for minimal puts: false
2006-04-11 17:08:20,895 INFO  hibernate.cfg.SettingsFactory  -> Query language substitutions: {}
2006-04-11 17:08:20,896 INFO  hibernate.cfg.SettingsFactory  -> cache provider: net.sf.hibernate.cache.EhCacheProvider
2006-04-11 17:08:20,905 DEBUG hibernate.cfg.SettingsFactory  -> Wrap result sets enabled? : false
2006-04-11 17:08:20,905 INFO  hibernate.cfg.Configuration  -> instantiating and configuring caches
2006-04-11 17:08:20,907 DEBUG sf.ehcache.CacheManager  -> Creating new CacheManager with default config
2006-04-11 17:08:20,911 DEBUG sf.ehcache.CacheManager  -> Configuring ehcache from classpath.
2006-04-11 17:08:20,923 WARN  ehcache.config.Configurator  -> No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/home/leandro/libs/hibernate-2.1/lib/ehcache-0.9.jar!/ehcache-failsafe.xml
2006-04-11 17:08:20,931 DEBUG ehcache.config.Configuration$DiskStore  -> Disk Store Path: /tmp
Exception in thread "main" java.lang.ExceptionInInitializerError
   at net.sf.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:805)
   at Main.main(Main.java:18)
Caused by: net.sf.cglib.core.CodeGenerationException: java.lang.reflect.InvocationTargetException-->null
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:236)
   at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:145)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:117)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
   at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
   at net.sf.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:237)
   ... 2 more
Caused by: java.lang.reflect.InvocationTargetException
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at net.sf.cglib.core.ReflectUtils.defineClass(ReflectUtils.java:373)
   at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:218)
   ... 7 more
Caused by: java.lang.IllegalAccessError: class net.sf.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory$$KeyFactoryByCGLIB$$601120ed cannot access its superinterface net.sf.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory
   at java.lang.ClassLoader.defineClass0(Native Method)
   at java.lang.ClassLoader.defineClass(ClassLoader.java:539)
   ... 13 more


Name and version of the database you are using:
MySQL 4.1


This is the Hello World Aplication from "Hibernate em Ação" first version.

Thank you.

Leandro

_________________
Leandro Mesquita de Morais


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 12, 2006 5:53 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Looks like classloading or versions mismatch issue

http://forum.hibernate.org/viewtopic.ph ... e830ede82c

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 1:13 pm 
Newbie

Joined: Tue Apr 11, 2006 5:08 pm
Posts: 4
I can't understand. How I fix this?

Tks.

_________________
Leandro Mesquita de Morais


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 13, 2006 1:46 pm 
Expert
Expert

Joined: Fri Jul 22, 2005 2:42 pm
Posts: 670
Location: Seattle, WA
Just check how your envirinment constructs the runtime classpath and make sure that proper versions of jars are in the classpath.

_________________
--------------
Konstantin

SourceLabs - dependable OpenSource systems


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 14, 2006 3:13 pm 
Newbie

Joined: Tue Apr 11, 2006 5:08 pm
Posts: 4
Konstantin, thank you.

I had a problem in the classpath. The application run fine in NetBeans but not in Eclipse. I change de way a build the classpath and then it runs. I spend so much time with this problem.

I was buildding the classpath folling the steps:

- right click on the current Java Project name in the Eclipse Package Explorer and click on Properties
- click on Java Build Class in the Properties window
- click on the Libraries tab
- click on the Add External JARs button
- enter the folder and the JAR file name
- click on the Open button
- click on the OK button at the bottom of the Properties window.

Then a change to a aplication paste /lib and put this in the classpath.

Don´t ask me why put now it runs.

Tks.

_________________
Leandro Mesquita de Morais


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