Olá pessoal!
Estou aprendendo a mexer com o hibernate mas ele insiste em dar erro nessa linha que chama o hibernate.cfg.xml:
/*
* Main.java
*
* Created on 29 de Março de 2007, 09:03
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package com.acme.helloworld;
import com.acme.helloworld.Aluno;
import java.sql.SQLException;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration;
/**
*
* @author danielm
*/
public class Main {
private static SessionFactory factory;
public static void main(String args[]){
Session session = getSession();
Transaction transaction = session.beginTransaction();
Aluno aluno = new Aluno();
aluno.setNome("Tião");
aluno.setMatricula(2003456);
aluno.setCpf(838392722);
session.save(aluno);
transaction.commit();
session.close();
}
static {
try {
factory = new Configuration().configure("hibernate.cfg.xml").buildSessionFactory();
} catch (Exception e) {
e.printStackTrace();
factory = null;
}
}
public static Session getSession() {
return factory.openSession();
}
}
Config do hibernate:
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.dialect">
org.hibernate.dialect.MySQLDialect
</property>
<property name="hibernate.connection.driver_class">
org.gjt.mm.mysql.Driver
</property>
<property name="hibernate.connection.url">
jdbc:mysql://inf011:3306/danieltestes?autoReconnect=true
</property>
<property name="hibernate.connection.username">
developer
</property>
<property name="hibernate.connection.password">
ecmdeveloper
</property>
<!-- Condiguração do c3p0 -->
<property name="hibernate.c3p0.max_size">10</property>
<property name="hibernate.c3p0.min_size">2</property>
<property name="hibernate.c3p0.timeout">5000</property>
<property name="hibernate.c3p0.max_statements">10</property>
<property name="hibernate.c3p0.idle_test_period">3000</property>
<property name="hibernate.c3p0.acquire_increment">2</property>
<!-- Configurações de debug -->
<property name="show_sql">true</property>
<property name="hibernate.generate_statistics">true</property>
<property name="hibernate.use_sql_comments">true</property>
<mapping resource="Aluno.hbm.xml"/>
</session-factory>
</hibernate-configuration>
O erro que ele dá é esse:
init:
deps-jar:
compile:
run:
java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at com.acme.helloworld.Main.<clinit>(Main.java:46)
Exception in thread "main"
Java Result: 1
EXECUTADO COM SUCESSO (tempo total: 0 segundos)