bonjour tout le monde,
j'ai vraiment besoin de votre aide merci. je travaille sur une application (un simple projet java)qui utilise hibernate . lors de l'execution il me genere l'exception suivante:
Code:
Exception in thread "main" java.lang.ExceptionInInitializerError
at hibernatePersonne.InitSessionFactory.<clinit>(InitSessionFactory.java:16)
at hibernatePersonne.Test.createPersonne(Test.java:100)
at hibernatePersonne.Test.main(Test.java:26)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@ca8327 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category) (Caused by org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@ca8327 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category))
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:543)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:235)
at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(LogFactoryImpl.java:209)
at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:351)
at org.hibernate.cfg.Configuration.<clinit>(Configuration.java:126)
... 3 more
Caused by: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@ca8327 for org.apache.commons.logging.impl.Log4JLogger (Caused by java.lang.NoClassDefFoundError: org/apache/log4j/Category)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:413)
at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
... 7 more
Caused by: java.lang.NoClassDefFoundError: org/apache/log4j/Category
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
at java.lang.Class.getConstructor0(Unknown Source)
at java.lang.Class.getConstructor(Unknown Source)
at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:410)
... 8 more
Caused by: java.lang.ClassNotFoundException: org.apache.log4j.Category
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 13 more
voila le fichier hibarnate.cfg.xml
Code:
<?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 name="factory">
<!-- local connection properties -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@127.0.0.1:1521:arabsoft</property>
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.username">gmao</property>
<property name="hibernate.connection.password">gmao</property>
<!-- property name="hibernate.connection.pool_size"></property -->
<!-- dialect for oracle -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>
<property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>
<!-- thread is the short name for
org.hibernate.context.ThreadLocalSessionContext
and let Hibernate bind the session automatically to the thread
-->
<property name="current_session_context_class">thread</property>
<!-- this will show us all sql statements -->
<property name="hibernate.show_sql">true</property>
<!-- mapping files -->
<mapping resource="hibernatePersonne/Personne.hbm.xml" />
</session-factory>
</hibernate-configuration>
le fichierPersonne.hbm.xml
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >
<hibernate-mapping>
<class name="hibernatePersonne.Personne" table="personne">
<id name="id"
column="id"
type="java.lang.String">
</id>
<property name="nom"
column="nom"
type="java.lang.String" />
<property name="prenom"
column="prenom"
type="java.lang.String" />
</class>
</hibernate-mapping>
et mon classe InitSessionFactory
Code:
package hibernatePersonne;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
public class InitSessionFactory {
public static final SessionFactory sessionFactory;
static {
try {
//CréelaSessionFactory
sessionFactory= new Configuration().configure("./hibernate.cfg.xml").buildSessionFactory();
}
catch (HibernateException ex){
throw new RuntimeException("Problèmedeconfiguration:" + ex.getMessage(), ex);
}
}
public static final ThreadLocal session= new ThreadLocal();
public static Session currentSession()
throws HibernateException{
Session s=(Session)session.get();
//OuvreunenouvelleSession,siceThreadn'enaaucune
if (s== null) {s = sessionFactory.openSession();
session.set(s);
}
return s;
}
public static void closeSession() throws HibernateException{
Session s=(Session)session.get();
session.set(null);
if (s!= null)
s.close();
}
}
merci d'avance .