-->
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: Exception in thread "main" bei simpler Hibernate-A
PostPosted: Fri Aug 12, 2005 7:27 am 
Newbie

Joined: Fri Aug 12, 2005 7:20 am
Posts: 3
Hallo zusammen,

ich arbeite mich grade in Hibernate ein und habe mit Eclipse eine kleine (und seeehr simple) Hibernate-Anwendung geschrieben.
Hibernate version: Hibernate 3
Mapping documents: Hibernate.hbm.xml

Hier die XML:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
    <class name="Hibernate" table="HIBERNATE">
        <id name="id" column="hID">
            <generator class="increment"/>
        </id>
        <property name="test1"/>
        <property name="test2"/>
        <property name="test3"/>
    </class>
</hibernate-mapping>


Hier der Source:
Code:
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;

public class Main {
   
       public static void main(String[] args) throws Exception {
         
        // 1. Build instance
        Hibernate data = new Hibernate();
        data.setTest1("test1");
        data.setTest2("test2");
        data.setTest3("test3");

        // 2. Fire up Hibernate
        Configuration cfg = new Configuration().addClass(Hibernate.class);
        SessionFactory sf = cfg.buildSessionFactory();

        // 3. Open Session
        Session sess = sf.openSession();

        // 4. Save instance and close Session
        Transaction t = sess.beginTransaction();
        sess.save(data);
        t.commit();
        sess.close();
   }

}


Ich bekomme IMMER diese verdammte :-) exception:
Code:
13:13:11,231  INFO Environment:464 - Hibernate 3.0.5
13:13:11,246  INFO Environment:482 - loaded properties from resource hibernate.properties: {hibernate.connection.username=root, hibernate.connection.password=****, hibernate.cglib.use_reflection_optimizer=true, hibernate.connection.pool_size=1, hibernate.dialect=org.hibernate.dialect.MySQLDialect, hibernate.connection.url=jdbc:mysql:///JDBC, hibernate.connection.driver_class=com.mysql.jdbc.Driver, hibernate.hbm2ddl.auto=create}
13:13:11,246  INFO Environment:510 - using CGLIB reflection optimizer
13:13:11,246  INFO Environment:540 - using JDK 1.4 java.sql.Timestamp handling
13:13:11,262  INFO Configuration:464 - Mapping resource: Hibernate.hbm.xml
13:13:11,450  INFO HbmBinder:260 - Mapping class: Hibernate -> HIBERNATE
13:13:11,465  INFO Configuration:875 - processing extends queue
13:13:11,465  INFO Configuration:879 - processing collection mappings
13:13:11,465  INFO Configuration:888 - processing association property references
13:13:11,465  INFO Configuration:917 - processing foreign key constraints
13:13:11,496  INFO DriverManagerConnectionProvider:41 - Using Hibernate built-in connection pool (not for production use!)
13:13:11,496  INFO DriverManagerConnectionProvider:42 - Hibernate connection pool size: 1
13:13:11,496  INFO DriverManagerConnectionProvider:45 - autocommit mode: false
13:13:11,512  INFO DriverManagerConnectionProvider:80 - using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql:///JDBC
13:13:11,512  INFO DriverManagerConnectionProvider:86 - connection properties: {user=root, password=****}
13:13:11,653  INFO SettingsFactory:77 - RDBMS: MySQL, version: 4.1.13a-nt
13:13:11,653  INFO SettingsFactory:78 - JDBC driver: MySQL-AB JDBC Driver, version: mysql-connector-java-3.1.10 ( $Date: 2005/05/19 15:52:23 $, $Revision: 1.1.2.2 $ )
13:13:11,653  INFO Dialect:92 - Using dialect: org.hibernate.dialect.MySQLDialect
13:13:11,653  INFO TransactionFactoryFactory:31 - Using default transaction strategy (direct JDBC transactions)
13:13:11,653  INFO TransactionManagerLookupFactory:33 - No TransactionManagerLookup configured (in JTA environment, use of read-write or transactional second-level cache is not recommended)
13:13:11,653  INFO SettingsFactory:125 - Automatic flush during beforeCompletion(): disabled
13:13:11,668  INFO SettingsFactory:129 - Automatic session close at end of transaction: disabled
13:13:11,668  INFO SettingsFactory:136 - JDBC batch size: 15
13:13:11,668  INFO SettingsFactory:139 - JDBC batch updates for versioned data: disabled
13:13:11,668  INFO SettingsFactory:144 - Scrollable result sets: enabled
13:13:11,668  INFO SettingsFactory:152 - JDBC3 getGeneratedKeys(): enabled
13:13:11,668  INFO SettingsFactory:160 - Connection release mode: null
13:13:11,668  INFO SettingsFactory:184 - Maximum outer join fetch depth: 2
13:13:11,668  INFO SettingsFactory:187 - Default batch fetch size: 1
13:13:11,668  INFO SettingsFactory:191 - Generate SQL with comments: disabled
13:13:11,668  INFO SettingsFactory:195 - Order SQL updates by primary key: disabled
13:13:11,668  INFO SettingsFactory:334 - Query translator: org.hibernate.hql.ast.ASTQueryTranslatorFactory
13:13:11,668  INFO ASTQueryTranslatorFactory:21 - Using ASTQueryTranslatorFactory
13:13:11,668  INFO SettingsFactory:203 - Query language substitutions: {}
13:13:11,668  INFO SettingsFactory:209 - Second-level cache: enabled
13:13:11,668  INFO SettingsFactory:213 - Query cache: disabled
13:13:11,668  INFO SettingsFactory:321 - Cache provider: org.hibernate.cache.EhCacheProvider
13:13:11,668  INFO SettingsFactory:228 - Optimize cache for minimal puts: disabled
13:13:11,668  INFO SettingsFactory:237 - Structured second-level cache entries: disabled
13:13:11,668  INFO SettingsFactory:261 - Statistics: disabled
13:13:11,668  INFO SettingsFactory:265 - Deleted entity synthetic identifier rollback: disabled
13:13:11,684  INFO SettingsFactory:279 - Default entity-mode: pojo
[color=red]Exception in thread "main" java.lang.ExceptionInInitializerError
   at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1005)
   at Main.main(Main.java:27)
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 org.hibernate.impl.SessionFactoryImpl.<clinit>(SessionFactoryImpl.java:321)
   ... 2 more
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 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 org.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory$$KeyFactoryByCGLIB$$f37b4e4d cannot access its superinterface org.hibernate.impl.SessionFactoryImpl$QueryCacheKeyFactory
   at java.lang.ClassLoader.defineClass1(Native Method)
   at java.lang.ClassLoader.defineClass(Unknown Source)
   ... 13 more[/color]

Kann mir jemand sagen, wo genau das Problem liegt bzw. woran es allgemein scheitern könnte?
Danke im Voraus!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 12, 2005 8:09 am 
Expert
Expert

Joined: Thu Dec 04, 2003 12:36 pm
Posts: 275
Location: Bielefeld, Germany
Hast du alle benötigten Klassen und JARs im Klassenpfad?

Zeig mal deine hibernate.properties bzw. deine hibernate.cfg.xml und ebenfalls deine Klasse Hibernate.java.

Schöne Grüße
Sven


Top
 Profile  
 
 Post subject: Re
PostPosted: Mon Aug 15, 2005 2:12 am 
Newbie

Joined: Fri Aug 12, 2005 7:20 am
Posts: 3
Hallo Zusammen,

es lag tatsächlich daran, dass die Jars nicht im Classpath lagen!" Dankeschön :-) Ciao...


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.