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 :

[Hibernate] Erreur de configuration ?


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    32
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 32
    Par défaut [Hibernate] Erreur de configuration ?
    Bonjour j'essaye de faire fonctionner ce petit bout de code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
    Session session= HibernateUtil.getSessionFactory().getCurrentSession();
    		Transaction tx = session.beginTransaction();
    		UserDTO user = new UserDTO();
    		user.setUserName("greg");
    		user.setPassword("greg2");
    		session.save(user);
    		tx.commit();
    Mais j'ai une erreur du type :

    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
     
     
    Initial SessionFactory creation failed.java.lang.ExceptionInInitializerError
    java.lang.ExceptionInInitializerError
    	at erasme.meg2.HibernateUtil.<clinit>(HibernateUtil.java:12)
    	at erasme.meg2.UserDAOHibernateTest.testGetUser(UserDAOHibernateTest.java:19)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    	at java.lang.reflect.Method.invoke(Unknown Source)
    	at junit.framework.TestCase.runTest(TestCase.java:154)
    	at junit.framework.TestCase.runBare(TestCase.java:127)
    	at junit.framework.TestResult$1.protect(TestResult.java:106)
    	at junit.framework.TestResult.runProtected(TestResult.java:124)
    	at junit.framework.TestResult.run(TestResult.java:109)
    	at junit.framework.TestCase.run(TestCase.java:118)
    	at junit.framework.TestSuite.runTest(TestSuite.java:208)
    	at junit.framework.TestSuite.run(TestSuite.java:203)
    	at junit.swingui.TestRunner$16.run(TestRunner.java:623)
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.) (Caused by org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.))
    	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:120)
    	... 15 more
    Caused by: org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (Caused by org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.)
    	at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:397)
    	at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(LogFactoryImpl.java:529)
    	... 19 more
    Caused by: org.apache.commons.logging.LogConfigurationException: Invalid class loader hierarchy.  You have more than one version of 'org.apache.commons.logging.Log' visible, which is not allowed.
    	at org.apache.commons.logging.impl.LogFactoryImpl.getLogConstructor(LogFactoryImpl.java:385)
    	... 20 more
    Voila le code de HibernateUtil :

    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
     
     
    package erasme.meg2;
     
    import org.hibernate.*;
    import org.hibernate.cfg.*;
     
    public class HibernateUtil {
    	private static final SessionFactory sessionFactory;
     
        static {
            try {
                // Create the SessionFactory from hibernate.cfg.xml
                sessionFactory = new Configuration().configure().buildSessionFactory();
            } catch (Throwable ex) {
                // Make sure you log the exception, as it might be swallowed
                System.err.println("Initial SessionFactory creation failed." + ex);
                ex.printStackTrace();
                throw new ExceptionInInitializerError(ex);
            }
        }
     
        public static SessionFactory getSessionFactory() {
            return sessionFactory;
        }
     
    }
    Voila l'arboresence des librairie que j'utilise :



    Je comprends pas vraiment d'où viens l'erreur.

  2. #2
    Membre expérimenté
    Profil pro
    Inscrit en
    Novembre 2006
    Messages
    156
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 156
    Par défaut
    Dans ton classpath, il y aurait au moins 2 jar commons-logging

  3. #3
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    32
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 32
    Par défaut
    ben c'est ce que j'avais cru comprendre aussi ... mais je suis dans eclispe ... les jar affiché plus haut sont dans le buid path ....

    et quand j'enlève la common login de la liste si dessus j'ai un class ot found exception :s

  4. #4
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Je pense plutôt que ton problème est dans hibernate.cfg.xml, peux-tu nous le montrer ?
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  5. #5
    Membre averti
    Profil pro
    Inscrit en
    Novembre 2005
    Messages
    32
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Novembre 2005
    Messages : 32
    Par défaut
    Le voici :

    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
     
     
    <?xml version='1.0' encoding='utf-8'?>
    <!DOCTYPE hibernate-configuration PUBLIC 
        "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
     
    <hibernate-configuration>
        <session-factory>
     
            <!-- Settings for a local MySQL database. -->
            <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
            <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
            <property name="connection.url">jdbc:mysql://localhost:3306/meg</property>
            <property name="connection.username">root</property>
            <property name="connection.password"></property>
     
            <!-- Use the C3P0 connection pool. -->
            <property name="c3p0.min_size">3</property>
            <property name="c3p0.max_size">5</property>
            <property name="c3p0.timeout">1800</property>
     
            <!-- Disable second-level cache. -->
            <property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
            <property name="cache.use_query_cache">false</property>
            <property name="cache.use_minimal_puts">false</property>
            <property name="max_fetch_depth">3</property>
     
            <!-- Print SQL to stdout. -->
            <property name="show_sql">true</property>
            <property name="format_sql">true</property>
     
            <!-- Bind the getCurrentSession() method to the thread. -->
            <property name="current_session_context_class">thread</property>
     
            <!-- Hibernate XML mapping files -->
            <mapping resource="erasme.meg.UserDTO.hbm.xml"/> 
     
        </session-factory>
     
    </hibernate-configuration>
    Merci

  6. #6
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Billets dans le blog
    1
    Par défaut
    Je crois me souvenir d'un problème identique et je n'avais pas trouvé le moyen de lui dire "pas de mot de passe", du coup, j'en avais mis un...
    Peux-tu essayer ça ?
    (ou alors essaye en retirant la ligne password)
    N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

Discussions similaires

  1. Eclipse-Hibernate-erreur Execution
    Par Invité dans le forum Hibernate
    Réponses: 18
    Dernier message: 22/06/2006, 09h37
  2. [Hibernate] Erreur de lecture
    Par magnus2005 dans le forum Hibernate
    Réponses: 2
    Dernier message: 05/05/2006, 23h51
  3. [Hibernate] Erreur de lecture
    Par magnus2005 dans le forum Hibernate
    Réponses: 2
    Dernier message: 24/01/2006, 16h47
  4. [VB.NET] Erreur de configuration
    Par toniolol dans le forum ASP.NET
    Réponses: 2
    Dernier message: 04/12/2005, 11h35
  5. [Hibernate] : Erreur Could not find datasource
    Par tipaquo dans le forum Hibernate
    Réponses: 2
    Dernier message: 12/10/2005, 10h43

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