-->
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.  [ 6 posts ] 
Author Message
 Post subject: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Fri Sep 18, 2009 7:23 pm 
Newbie

Joined: Fri Sep 18, 2009 5:59 pm
Posts: 3
Hallo zusammen,

ich hab grade mit Hibernate angefangen und versucht ein Beispiel auszuführen. Es geht leider nicht wegen einem Bug das ich nicht weiss warum. Bitte mal helfen.
Die Felhlermeldung sieht so aus :

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at Test.main(Test.java:9)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more





Hier ist meine SourceCode :



// Java Class "Message" :

package hello;

import java.io.Serializable;

public class Message implements Serializable{
private int id;
private String text;

public Message() {}

public Message(String text) {
this.text = text;
}
public int getId() {
return id;
}
private void setId(int id) {
this.id = id;
}
public String getText() {
return text;
}
public void setText(String text) {
this.text = text;
}

}


// Hibernate mapping file für Message :

<?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="hello.Message" table="MESSAGES">
<id name="id" column="MESSAGE_ID">
<generator class="increment" />
</id>
<property name="text" column="MESSAGE_TEXT" type="String" />
</class>
</hibernate-mapping>



//Hibernate config. file :

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->

<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3308/test</property>
<property name="connection.username">admin_MSG</property>
<property name="connection.password">admin_MSG</property>
<property name = "hibernate.query.factory_class">org.hibernate.hql.classic.ClassicQueryTranslatorFactory</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.MySQL5Dialect</property>

<!-- Enable Hibernate's automatic session context management -->
<property name="current_session_context_class">thread</property>

<!-- Disable the second-level cache -->
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>

<!-- Echo all executed SQL to stdout
<property name="show_sql">true</property> -->

<!-- Drop and re-create the database schema on startup
<property name="hbm2ddl.auto">create</property>-->



<mapping resource="hello/Message.hbm.xml"/>


</session-factory>

</hibernate-configuration>



// main methode steht hier, in Class Test :

import org.hibernate.*;
import org.hibernate.cfg.Configuration;

public class Test {

public static void main(String[] args) {


Configuration cfg = new Configuration();
SessionFactory factory = cfg.buildSessionFactory();
Session session = factory.openSession();

Transaction tx = session.beginTransaction();
hello.Message message = new hello.Message("Hello World 2");
session.save(message);
System.out.println(message.getText());
tx.commit();
session.close();



}

}



und ich habe diese Fehlermeldung bekommen :

Exception in thread "main" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at Test.main(Test.java:9)
Caused by: java.lang.ClassNotFoundException: org.dom4j.DocumentException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at sun.misc.Launcher$ExtClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 1 more


Top
 Profile  
 
 Post subject: Re: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Fri Sep 18, 2009 8:15 pm 
Senior
Senior

Joined: Mon Jul 07, 2008 4:35 pm
Posts: 141
Location: Berlin
Hi dustinwind,

da fehlt wohl dom4j im classpath...

Kriegst du hier: http://www.dom4j.org/

CU
Froestel

_________________
Have you tried turning it off and on again? [Roy]


Top
 Profile  
 
 Post subject: Re: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Mon Sep 21, 2009 1:29 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Der Hibernate-Download beinhaltet bis auf die konkrete Logger-Implementierung alle jars, die man braucht. Der Ordner, der die benötigten jars enthält, trägt auch noch den Namen "required"...


Top
 Profile  
 
 Post subject: Re: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Mon Sep 21, 2009 5:07 am 
Newbie

Joined: Fri Sep 18, 2009 5:59 pm
Posts: 3
Ich hab eigentlich schon alle nötigen Jars in Classpath, natürlich dom4j auch schon dabei, aber immer noch dieser Fehler.
Was sollte das sein? :(


Top
 Profile  
 
 Post subject: Re: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Mon Sep 21, 2009 5:14 am 
Senior
Senior

Joined: Tue Oct 28, 2008 10:39 am
Posts: 196
Mit welcher IDE arbeitest du? Bist du *sicher*, dass die jars alle im CLASSPATH sind? Denn das dom4j.jar enthält die Klasse definitiv.


Top
 Profile  
 
 Post subject: Re: Hibernate bug im ersten Beispiel, bitte helfen
PostPosted: Tue Sep 22, 2009 6:55 pm 
Newbie

Joined: Fri Sep 18, 2009 5:59 pm
Posts: 3
Ich hab Eclipse Ganymede
In Classpath habe ich eigentlich schon fast alle jar Dateien hinuigefügt, was mit Hibernate_core und Hibernate_annotation relevant sind (dom4j ist auch schon dabei).
Was soll das sein? Bitte helfen


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