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 pb SessionFactory


Sujet :

Hibernate Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Points : 68
    Points
    68
    Par défaut Hibernate Definition ID avec annotations
    Bonjour
    Je dev une app avec Hibernate annotation voici mon erreur
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
     
    INFO: Configured SessionFactory: null
    Initial SessionFactory creation failed.java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;
    Exception in thread "main" java.lang.ExceptionInInitializerError
    	at util.HibernateUtil.<clinit>(HibernateUtil.java:16)
    	at test.Example1.main(Example1.java:20)
    Caused by: java.lang.NoSuchMethodError: org.hibernate.util.ReflectHelper.classForName(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Class;
    	at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:752)
    	at util.HibernateUtil.<clinit>(HibernateUtil.java:11)
    	... 1 more
    quelqu'un a une solution??

  2. #2
    Membre chevronné
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Points : 1 787
    Points
    1 787
    Par défaut
    Ma boule de cristal, mais où est ma boule de cristal !!!!
    Ah ben désolé, je ne vais pas pouvoir te répondre sans elle

    Plus sérieusement, si tu nous donnait un peu le code de HibernateUtil et les lignes correspondantes, ça aiderait ...

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Points : 68
    Points
    68
    Par défaut
    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
    1package util;
    
    import org.hibernate.SessionFactory;
    import org.hibernate.cfg.AnnotationConfiguration;
    
    public class HibernateUtil {
      private static final SessionFactory sessionFactory;
      static {
        try {
          // Create the SessionFactory from hibernate.cfg.xml
          sessionFactory = new AnnotationConfiguration().configure().buildSessionFactory();
        } 
        catch (Throwable ex) {
          // Make sure you log the exception, as it might be swallowed
          System.err.println("Initial SessionFactory creation failed." + ex);
          throw new ExceptionInInitializerError(ex);
        }
      }
    
      public static SessionFactory getSessionFactory() {
        return sessionFactory;
      }
    }
    voila

  4. #4
    Membre chevronné
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Points : 1 787
    Points
    1 787
    Par défaut
    Tu peux nous mettre ton hibernate.cfg.xml ?

  5. #5
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Points : 68
    Points
    68
    Par défaut
    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
    <!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
    <hibernate-configuration>
     
    	<session-factory>
     
    		<!-- Database connection settings -->
    		<property name="connection.driver_class">
    			com.mysql.jdbc.Driver
    		</property>
    		<property name="connection.url">
    			jdbc:mysql://127.0.0.1:3306/bdtest
    		</property>
    		<property name="connection.username">root</property>
    		<property name="connection.password">root</property>
    		<!-- JDBC connection pool (use the built-in) -->
    		<property name="connection.pool_size">1</property>
    		<!-- SQL dialect -->
    		<property name="dialect">
    			org.hibernate.dialect.MySQLDialect
    		</property>
    		<!-- Enable Hibernate's automatic session context management -->
    		<property name="current_session_context_class">thread</property>
    		<!-- Disable the second-level cache -->
    		<property name="cache.provider_class">
    			org.hibernate.cache.NoCacheProvider
    		</property>
    		<!-- Echo all executed SQL to stdout -->
    		<property name="show_sql">true</property>
     
     
    		<mapping class="employe.Employee" />
     
     
    	</session-factory>
    </hibernate-configuration>

  6. #6
    Membre chevronné
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Points : 1 787
    Points
    1 787
    Par défaut
    En fait je pense que ton jar hibernate-core et ton jar hibernate-annotations ne sont pas compatibles ... Tu peux essayer de prendre les dernières versions des deux ?

  7. #7
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Points : 68
    Points
    68
    Par défaut
    Sa y est ca marche maintenant je ne sais pas comment je definit l'Id pour qu'il soit en auto incremente??

  8. #8
    Membre chevronné
    Homme Profil pro
    Directeur technique
    Inscrit en
    Janvier 2007
    Messages
    1 348
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Paris (Île de France)

    Informations professionnelles :
    Activité : Directeur technique

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 348
    Points : 1 787
    Points
    1 787
    Par défaut
    Cétait bien un problème de version de jars ? Si oui tag en résolu stp et si tu as une question sur les id autoincrement ca serait mieux de faire un thread séparé ...

  9. #9
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2007
    Messages
    130
    Détails du profil
    Informations personnelles :
    Localisation : Suisse

    Informations forums :
    Inscription : Avril 2007
    Messages : 130
    Points : 68
    Points
    68
    Par défaut
    Oui c'etait un pb de jar dsl de n'avoir pas mis resolu

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [JSP - HIBERNATE] Problème sessionFactory dans JSP
    Par vrossi59 dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 24/03/2009, 01h21
  2. [Data] [Spring/Hibernate] sessionFactory null
    Par AyreoN dans le forum Spring
    Réponses: 3
    Dernier message: 12/11/2008, 17h48
  3. [Data] [Hibernate] Initialisation de la "sessionFactory"
    Par FreshVic dans le forum Spring
    Réponses: 1
    Dernier message: 02/10/2008, 11h47
  4. Réponses: 8
    Dernier message: 17/04/2008, 17h29
  5. [Hibernate] probleme de SessionFactory
    Par Elmilouse dans le forum Hibernate
    Réponses: 2
    Dernier message: 11/04/2006, 16h52

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