salut tous le monde,
je suis entrein de construire mon application avec hibernate.il me genere une erreur que j'ai pas pu la correger.et vraiment je suis perdu
le voila l'erreur :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
Exception in thread "main" java.lang.ExceptionInInitializerError
	at hibernatePersonne.InitSessionFactory.<clinit>(InitSessionFactory.java:16)
	at hibernatePersonne.Test.createPersonne(Test.java:103)
	at hibernatePersonne.Test.main(Test.java:29)
Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: No suitable Log constructor [Ljava.lang.Class;@55571e 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;@55571e 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;@55571e 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
et la classe InitSessionFactory la voila
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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 de m'aider