Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
2753 connectés 

  FORUM HardWare.fr
  Programmation
  Java

  hibernate problème

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

hibernate problème

n°1870907
fifo82
Posté le 08-04-2009 à 10:13:21  profilanswer
 

slt tout le monde,
voila j'ai un petit problème, j'ai réalisé une application qui utilise hibernate, mais je n'arrive pas à l'exécuter, j'ai tjrs cette erreur.
j'utilise NtBeans 6.5

Citation :

Exception in thread "main" java.lang.ExceptionInInitializerError
        at com.test.rsyncModel.HibernateUtil.<clinit>(HibernateUtil.java:30)
        at com.test.rsyncModel.EventManager.getPersonne(EventManager.java:29)
        at com.test.rsyncModel.EventManager.main(EventManager.java:20)
Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V
        at net.sf.cglib.core.DebuggingClassWriter.<init>(DebuggingClassWriter.java:47)
        at net.sf.cglib.core.DefaultGeneratorStrategy.getClassWriter(DefaultGeneratorStrategy.java:30)
        at net.sf.cglib.core.DefaultGeneratorStrategy.generate(DefaultGeneratorStrategy.java:24)
        at net.sf.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:216)
        at net.sf.cglib.core.KeyFactory$Generator.create(KeyFactory.java:144)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:116)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:108)
        at net.sf.cglib.core.KeyFactory.create(KeyFactory.java:104)
        at net.sf.cglib.proxy.Enhancer.<clinit>(Enhancer.java:69)
        at org.hibernate.proxy.pojo.cglib.CGLIBLazyInitializer.getProxyFactory(CGLIBLazyInitializer.java:117)
        at org.hibernate.proxy.pojo.cglib.CGLIBProxyFactory.postInstantiate(CGLIBProxyFactory.java:43)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.buildProxyFactory(PojoEntityTuplizer.java:162)
        at org.hibernate.tuple.entity.AbstractEntityTuplizer.<init>(AbstractEntityTuplizer.java:135)
        at org.hibernate.tuple.entity.PojoEntityTuplizer.<init>(PojoEntityTuplizer.java:55)
        at org.hibernate.tuple.entity.EntityEntityModeToTuplizerMapping.<init>(EntityEntityModeToTuplizerMapping.java:56)
        at org.hibernate.tuple.entity.EntityMetamodel.<init>(EntityMetamodel.java:295)
        at org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:434)
        at org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:109)
        at org.hibernate.persister.PersisterFactory.createClassPersister(PersisterFactory.java:55)
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:226)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1294)
        at com.test.rsyncModel.HibernateUtil.<clinit>(HibernateUtil.java:25)


ma classe Personne

Code :
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.test.rsyncBean;
  6. import com.test.*;
  7. /**
  8. *
  9. * @author zenadm
  10. */
  11. public class Personne {
  12.     private String idPersonne;
  13.     private String perIdPersonne;
  14.     private String nom;
  15.     private String prenom;
  16.     private String email;
  17.     private String tel;
  18.     private Compte compte;
  19.    
  20.     public Personne(){
  21.      
  22.     }
  23.     public String getEmail() {
  24.         return email;
  25.     }
  26.     public void setEmail(String email) {
  27.         this.email = email;
  28.     }
  29.     public String getNom() {
  30.         return nom;
  31.     }
  32.     public void setNom(String nom) {
  33.         this.nom = nom;
  34.     }
  35.     public String getPrenom() {
  36.         return prenom;
  37.     }
  38.     public void setPrenom(String prenom) {
  39.         this.prenom = prenom;
  40.     }
  41.     public Compte getCompte() {
  42.         return compte;
  43.     }
  44.     public void setCompte(Compte compte) {
  45.         this.compte = compte;
  46.     }
  47. }


mon fichier mapping hibernate

Code :
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  3. <hibernate-mapping>
  4.   <class name="com.test.rsyncBean.Personne" table="personne">
  5.     <id column="ID_PERSONNE" name="idPersonne" type="int">
  6.       <generator class="native"/>
  7.     </id>
  8.     <property column="PER_ID_PERSONNE" name="perIdPersonne" not-null="true" type="string"/>
  9.     <property column="NOM" name="nom" not-null="true" type="string"/>
  10.     <property column="PRENOM" name="prenom" not-null="true" type="string"/>
  11.     <property column="EMAIL" name="email" not-null="true" type="date"/>
  12.     <property column="TEL" name="tel" not-null="false" type="double"/>
  13.   </class>
  14. </hibernate-mapping>


 
puis mon fichier conf

Code :
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  3. <hibernate-configuration>
  4.     <session-factory>
  5.          <!-- SQL dialect -->
  6.         <property name="hibernate.dialect"> org.hibernate.dialect.MySQLInnoDBDialect</property>
  7.     <!-- Database connection settings -->
  8.         <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  9.         <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/rsynfgergcdb</property>
  10.         <property name="hibernate.connection.username">rsync</property>
  11.         <property name="hibernate.connection.password">qfrzqenrgreghh4you</property>
  12.      <!-- JDBC connection pool (use the built-in) -->
  13.         <property name="hibernate.connection.pool_size">1</property>
  14.         <!-- Echo all executed SQL to stdout -->
  15.         <property name="hibernate.show_sql">true</property>
  16.         <!-- Enable Hibernate's automatic session context management -->
  17.         <property name="hibernate.current_session_context_class">thread</property>
  18.         <!-- Drop and re-create the database schema on startup -->
  19.         <property name="hibernate.hbm2ddl.auto">create</property>
  20.         <mapping resource="com/test/rsyncBean/Personne.hbm.xml"/>
  21.     </session-factory>
  22. </hibernate-configuration>


 
et pour exécuter tout ça j'utilise le deux classes surventes :

Code :
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.test.rsyncModel;
  6. import org.hibernate.SessionFactory;
  7. import org.hibernate.cfg.Configuration;
  8. /**
  9. *
  10. * @author zenadm
  11. */
  12. //import org.hibernate.*;
  13. //import org.hibernate.cfg.*;
  14. public class HibernateUtil {
  15.     private static final SessionFactory sessionFactory;
  16.     static {
  17.         try {
  18.             // Create the SessionFactory from hibernate.cfg.xml
  19.             sessionFactory = new Configuration().configure().buildSessionFactory();
  20.            
  21.         } catch (Throwable ex) {
  22.             // Make sure you log the exception, as it might be swallowed
  23.             System.err.println("Initial SessionFactory creation failed." + ex);
  24.             throw new ExceptionInInitializerError(ex);
  25.         }
  26.     }
  27.     public static SessionFactory getSessionFactory() {
  28.         return sessionFactory;
  29.     }
  30. }


 
enfin ma classe main:

Code :
  1. /*
  2. * To change this template, choose Tools | Templates
  3. * and open the template in the editor.
  4. */
  5. package com.test.rsyncModel;
  6. import com.test.rsyncBean.Personne;
  7. import org.hibernate.Session;
  8. public class EventManager {
  9.     public static void main(String[] args) {
  10.         EventManager mgr = new EventManager();
  11.    
  12.             mgr.getPersonne();
  13.             System.out.println(mgr);
  14.        
  15.         HibernateUtil.getSessionFactory().close();
  16.     }
  17.     private String getPersonne() {
  18.         Session session = HibernateUtil.getSessionFactory().getCurrentSession();
  19.         session.beginTransaction();
  20.         Personne thePersonne = new Personne();
  21.         thePersonne.getNom();
  22.         thePersonne.getPrenom();
  23.         session.save(thePersonne);
  24.         session.getTransaction().commit();
  25.         return thePersonne.getNom()+thePersonne.getPrenom();
  26.     }
  27. }


 
Help!!!!!!!!!!
glasgow est actuellement connecté Signaler un message hors-charte    Envoyer un message privé Modifier/Supprimer le message


Message édité par fifo82 le 08-04-2009 à 14:06:35
mood
Publicité
Posté le 08-04-2009 à 10:13:21  profilanswer
 

n°1870918
brisssou
8-/
Posté le 08-04-2009 à 10:41:10  profilanswer
 

Caused by: java.lang.NoSuchMethodError: org.objectweb.asm.ClassWriter.<init>(I)V  
 
un petit soucis de version de ASM ?
est-ce que ton serveur n'aurait pas une autre version de cette bibliothèque que celle attendue par Hibernate ?
 


---------------
HFR - Mes sujets pour Chrome - Firefox - vérifie les nouveaux posts des topics suivis/favoris
n°1870920
fifo82
Posté le 08-04-2009 à 10:46:08  profilanswer
 

je ne sais pas en tout cas dans le fichier MANIFEST.MF,
j'ai les informations suivantes
 
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
Implementation-Title: ASM
Implementation-Version: 1.5.3
 
sais tu comment dois je faire pour vérifier ceci, sachant que j'utilise Netbeans 6.5.

n°1870931
brisssou
8-/
Posté le 08-04-2009 à 11:03:14  profilanswer
 

et ton serveur J2EE, c'est quoi ?
 
est-ce qu'il n'y a pas déjà une version de ASM livrée par lui ?
Est-ce que dans l'arborescence de ton serveur tu n'a pas un répertoire lib dans lequel tu vas trouver un fichier asm-X.Y.Z.jar ? avec X.Y.Z différent de la version attendue par Hibernate ?
 
Si oui, il va falloir modifier la politique de chargement des classes.
 
Par défaut, quand tu appelles une classe, ton serveur la cherche dans la JVM, puis dans les bibliothèques qu'il livre, puis dans celles que tu livres dans ton EAR, après dans le WAR, et enfin dans ton code (WEB-INF/classes). C'est le comportement PARENT_FIRST.
 
Tu peux modifier ce comportement en passant en PARENT_LAST. Ça règlera probablement ton problème, mais c'est potentiellement dangereux.


---------------
HFR - Mes sujets pour Chrome - Firefox - vérifie les nouveaux posts des topics suivis/favoris
n°1870938
fifo82
Posté le 08-04-2009 à 11:12:00  profilanswer
 

enfait j'utilise Glassfish 2, tout ce que j'ai fait et telecharger netbeans 6.5, le serveur il est installé par default, hibernate aussi, la seule chose que j'ai telechargée c'était JDBC.
tu pense que ej dois toujours changé mon ASM, et d'ailleurs je trouve pas le X.Y.Z, dont tu as parlé.
merci

n°1871000
brisssou
8-/
Posté le 08-04-2009 à 11:59:47  profilanswer
 

tu le trouveras alors dans le menifest, comme tu as fais plus haut.


---------------
HFR - Mes sujets pour Chrome - Firefox - vérifie les nouveaux posts des topics suivis/favoris
n°1871008
fifo82
Posté le 08-04-2009 à 12:03:52  profilanswer
 

il y est pas dans le manifest, je trouve seulement :
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.5.0_01-b08 (Sun Microsystems Inc.)
Implementation-Title: ASM
Implementation-Version: 1.5.3
Implementation-Vendor: France Telecom R&D
 

n°1871018
fifo82
Posté le 08-04-2009 à 12:10:39  profilanswer
 

enfait dans mon Hibernate-asm. jar est présenté comme suite:
- Hibernate-asm. jar
   -META-INF
       MANIFEST.MF
    -ORG
       -objectweb
           -asm
                  Attribute.class
                  ByteVector.class
                   ClassAdapter.class
                    ......etc.class
 
et dans mon fichier MANIFEST, il y a ce que j'ai envoyé dans le post précédent.
j'ai rémarqué aussi qu'il y a un deuxième jar qui s'appelle Hibernate-asm-attres.jar, mais il ressemble beaucoup à Hibernate-asm.jar

n°1871096
fifo82
Posté le 08-04-2009 à 14:29:03  profilanswer
 

dans mon serveur glassfish il n'y a pas ASM

n°1871098
brisssou
8-/
Posté le 08-04-2009 à 14:29:32  profilanswer
 

http://forum.hibernate.org/viewtopic.php?p=2386851
 
cf. le dernier post
 
tu supprimes la bibliothèque Jersey de ton classpath, et ça devrait rouler


---------------
HFR - Mes sujets pour Chrome - Firefox - vérifie les nouveaux posts des topics suivis/favoris
mood
Publicité
Posté le 08-04-2009 à 14:29:32  profilanswer
 

n°1871122
fifo82
Posté le 08-04-2009 à 14:54:40  profilanswer
 

il est dit dans le dernier post, que Netbeans ajoute Jersey, cependant je ne le trouve pas, ni dans les librairies, ni quelque part ailleurs.

n°1871141
brisssou
8-/
Posté le 08-04-2009 à 15:11:34  profilanswer
 

j'ai plus d'idée
 
désolé


---------------
HFR - Mes sujets pour Chrome - Firefox - vérifie les nouveaux posts des topics suivis/favoris
n°1871144
fifo82
Posté le 08-04-2009 à 15:14:53  profilanswer
 

merci beaucoup, si jamais je trouverai la solution un jour, si tu veux je la poste ici.


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation
  Java

  hibernate problème

 

Sujets relatifs
Problème session[PHP} Probleme boucle
Problème MVC <-> HibernateHibernate -> problème de mapping
[hibernate] problème avec une reqûete en HQL qui utilise un 'map'[hibernate + eclipse] probleme de mapping et de compilation
[hibernate] probleme avec un filtre, et DB2 : "invalid parameter nb"[Debutant] Problème Hibernate
[hibernate] Problème avec les requetesproblème hibernate - linux - encoding
Plus de sujets relatifs à : hibernate problème


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR