IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Hibernate Java Discussion :

exception :No suitable Log constructor


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2007
    Messages
    198
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2007
    Messages : 198
    Par défaut exception :No suitable Log constructor
    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 : 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: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 : 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
    <?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 : 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
    <?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 : 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 d'avance

  2. #2
    Expert confirmé
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Par défaut
    Bonjour,
    Il te manque log4j.jar dans le classpath ...

  3. #3
    Membre confirmé
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2007
    Messages
    198
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2007
    Messages : 198
    Par défaut
    salut,
    j'ai fait BuildPath -->configureBuildPath puis j'ai fait Add external jar

    j'ai importe toutes les jars y contient le log4j-1.2.11

    merci

  4. #4
    Expert confirmé
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Par défaut
    Oui, mais est ce que ce jar est coché dans la section J2EE module dependencies ?

  5. #5
    Membre confirmé
    Femme Profil pro
    Étudiant
    Inscrit en
    Août 2007
    Messages
    198
    Détails du profil
    Informations personnelles :
    Sexe : Femme

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Août 2007
    Messages : 198
    Par défaut
    je m'excuse mais j'ai pas compris est ce que veos pouvez m'expliquer?

  6. #6
    Expert confirmé
    Avatar de djo.mos
    Profil pro
    Inscrit en
    Octobre 2004
    Messages
    4 666
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2004
    Messages : 4 666
    Par défaut
    Dans eclipse, project, properties, tu trouveras à gauche une section J2EE module dependencies
    De là, à droite, y'a tes jars.
    Vérifies que log4j est coché.

Discussions similaires

  1. Réponses: 3
    Dernier message: 27/05/2012, 13h25
  2. Réponses: 0
    Dernier message: 25/03/2009, 10h41
  3. [Debug] Rediriger les exceptions JAVA dans un log
    Par matt8-5 dans le forum Logging
    Réponses: 3
    Dernier message: 25/01/2008, 11h34
  4. [JDBC][Débutant] Exception : No suitable driver
    Par Prophetis dans le forum JDBC
    Réponses: 7
    Dernier message: 24/10/2005, 23h50

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo