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 + mysql + tomcat


Sujet :

Hibernate Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2005
    Messages : 163
    Par défaut hibernate + mysql + tomcat
    Bonjour,
    J'ai une erreur d'éxécution que j'arrive pas a resoudre vu ke je suis debutant ds se domaine.
    l'erreur est la suivante :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    Initial SessionFactory creation failed.java.lang.NoClassDefFoundError: org/dom4j/Attribute
    Exception in thread "main" java.lang.ExceptionInInitializerError
    	at istia.st.springmvc.personnes.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:17)
    	at Test.main(Test.java:9)
    Caused by: java.lang.NoClassDefFoundError: org/dom4j/Attribute
    	at istia.st.springmvc.personnes.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:13)
    	... 1 more
    je vous donne les principaux fichiers qui interviennent, c'est trop long je sais ,si vous avez un peu de temps jetez un coup d'oeuil
    merci

    ma classe de test est :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    import java.util.*;
    import net.sf.hibernate.*;
    import istia.st.springmvc.personnes.hibernate.*;
     
    public class Test {
     
     public static void main(String[] args)
    	throws HibernateException {
            Session s = HibernateUtil.currentSession();
            HibernateUtil.closeSession();
            System.exit(0);    
     }
    }
    ma classe HibernateUtil est :
    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
    public class HibernateUtil {
     
        private static final SessionFactory sessionFactory;
     
        static {
            try {
                // Create the SessionFactory
                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);
                throw new ExceptionInInitializerError(ex);
            }
        }
     
        public static final ThreadLocal session = new ThreadLocal();
     
        public static Session currentSession() throws HibernateException {
            Session s = (Session) session.get();
            // Open a new Session, if this Thread has none yet
            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();
        }
    }
    mon fichier hibernate.cfg.xml est
    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
    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE hibernate-configuration
        PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN"
        "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
     
    <hibernate-configuration>
    	<session-factory>
    		<!-- local connection properties -->
    		<property name="hibernate.connection.url">
    			jdbc:mysql://localhost/dbpersonnes
    		</property>
    		<property name="hibernate.connection.driver_class">
    			com.mysql.jdbc.Driver
    		</property>
    		<property name="hibernate.connection.username">root</property>
    		<property name="hibernate.connection.password" />
    		<!-- property name="hibernate.connection.pool_size"></property -->
    		<!-- dialect for MySQL -->
    		<property name="dialect">
    			net.sf.hibernate.dialect.MySQLDialect
    		</property>
    		<property name="hibernate.show_sql">false</property>
    		<property name="hibernate.use_outer_join">true</property>
     
    		<property name="hibernate.transaction.factory_class">
    			net.sf.hibernate.transaction.JTATransactionFactory
    		</property>
    		<property name="jta.UserTransaction">
    			java:comp/UserTransaction
    		</property>
     
     
    		<mapping resource="Personnes.hbm.xml" />
    	</session-factory>
    </hibernate-configuration>
    et finalement mon fichier hbm est
    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
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    <?xml version="1.0"?>
    <!DOCTYPE hibernate-mapping PUBLIC
    	"-//Hibernate/Hibernate Mapping DTD//EN"
    	"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
     
    <hibernate-mapping package="istia.st.springmvc.personnes.hibernate">
    	<class name="Personnes" table="personnes">
    		<id
    			column="ID"
    			name="Id"
    			type="integer"
    		>
    			<generator class="increment"/>
    		</id>
    		<property
    			column="VERSION"
    			length="11"
    			name="Version"
    			not-null="false"
    			type="integer"
    		 />
    		<property
    			column="DATENAISSANCE"
    			length="10"
    			name="Datenaissance"
    			not-null="false"
    			type="date"
    		 />
    		<property
    			column="NOM"
    			length="20"
    			name="Nom"
    			not-null="false"
    			type="string"
    		 />
    		<property
    			column="PRENOM"
    			length="20"
    			name="Prenom"
    			not-null="false"
    			type="string"
    		 />
    		<property
    			column="NBENFANTS"
    			length="11"
    			name="Nbenfants"
    			not-null="false"
    			type="integer"
    		 />
    		<property
    			column="MARIE"
    			length="11"
    			name="Marie"
    			not-null="false"
    			type="integer"
    		 />
    	</class>
    </hibernate-mapping>

  2. #2
    Membre Expert
    Profil pro
    Inscrit en
    Août 2006
    Messages
    3 276
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Août 2006
    Messages : 3 276
    Par défaut
    Il te manque un jar nécessaire au bon fonctionnement d'Hibernate.
    Va voir la doc, il y a la liste des jars indispensables.

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2005
    Messages : 163
    Par défaut
    ok je vais voir
    merci

  4. #4
    Membre confirmé
    Profil pro
    Inscrit en
    Avril 2005
    Messages
    163
    Détails du profil
    Informations personnelles :
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations forums :
    Inscription : Avril 2005
    Messages : 163
    Par défaut
    effectivement t'avais raison, il y avait un jar qui manquer. merci bien
    Sinon, est ce que tu peux me dire comment faire marcher cette petite appli avec Tomcat, est ce qu'il suffira d'appeller les methodes d'hibernate depuis la couche DAO ?

Discussions similaires

  1. Réponses: 1
    Dernier message: 22/01/2013, 00h07
  2. Optimisation Application Java (Hibernate, Mysql, Tomcat)
    Par adil_vpb dans le forum Tomcat et TomEE
    Réponses: 4
    Dernier message: 25/07/2012, 09h56
  3. Réponses: 3
    Dernier message: 24/03/2010, 14h57
  4. Problème déploiement Tomcat,Hibernate,MySQL
    Par FunkyBreizh dans le forum MySQL
    Réponses: 0
    Dernier message: 30/06/2009, 14h53
  5. Réponses: 10
    Dernier message: 25/02/2009, 16h34

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