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 :

mon projet ne marche plus erreur


Sujet :

Hibernate Java

  1. #1
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut mon projet ne marche plus erreur
    bonjour,

    voila, ca fait longtemps que je n'etais plus sur mon projet hibernate et le probleme c'est que j'ai oublié la solution a cette erreur :

    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
     
     
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" javax.persistence.PersistenceException: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
    	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
    	at ControlleurMD.Liste.main(Liste.java:14)
    Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    	at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:70)
    	at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:89)
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:215)
    	... 4 more
    En faite, mon projet contient une classe produit et une classe catalogue.
    une autre classe Liste.java comme defini ici:

    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
     
    package ControlleurMD;
     
    import java.util.List;
     
    import javax.persistence.*;
    import ModeleMD.*;
     
    public class Liste {
     
     
    	@SuppressWarnings("unchecked")
    	public static void main(String[] args) {
     
    		EntityManagerFactory emf = Persistence.createEntityManagerFactory("manager1");
    		EntityManager em = emf.createEntityManager();
    		em.getTransaction().begin();
    		List<Catalogue> catalogues = (List<Catalogue>) em.createNativeQuery("select * from tabcatalogue", Catalogue.class).getResultList();
    		for(Catalogue it: catalogues){
    			System.out.println(it.getId()+" "+it.getNom()+"\n");
    			List<Produit> produits = (List<Produit>) em.createNativeQuery("select * from tabproduit where catalogue_id="+it.getId()+"", Produit.class).getResultList();
    			for(Produit iter: produits){
    				System.out.println(iter.getCode()+" "+iter.getDesignation()+" "+iter.getAcheteur()+" "+iter.getPrix());
    			}
    		}
     
    		em.getTransaction().commit();
    		em.close();
    		emf.close();
     
    	}
     
    }
    me permet d'avoir la liste des produits par catalogue.
    Jusque la tout va bien car avant il me retournait dans la console le resultat de mes requetes.
    Or, comme cela fait longtemps que j'y ai plus touché et qu'avant cela fonctionnait maintenant le probleme c'est que je me souvient plus pkoi ca ne fonctionne pas car j'ai cette erreur, bien que mon fichier de config a été configurer au préalable:
    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
     
     
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
    log4j:WARN Please initialize the log4j system properly.
    Exception in thread "main" javax.persistence.PersistenceException: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:258)
    	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:120)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:51)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:33)
    	at ControlleurMD.Liste.main(Liste.java:14)
    Caused by: org.xml.sax.SAXParseException: The content of elements must consist of well-formed character data or markup.
    	at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)
    	at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)
    	at org.hibernate.ejb.packaging.PersistenceXmlLoader.loadURL(PersistenceXmlLoader.java:70)
    	at org.hibernate.ejb.packaging.PersistenceXmlLoader.deploy(PersistenceXmlLoader.java:89)
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:215)
    	... 4 more
    si quelqu'un peut m'aider merci

  2. #2
    Membre actif Avatar de mOuLi
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2008
    Messages
    170
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Avril 2008
    Messages : 170
    Points : 257
    Points
    257
    Par défaut
    Une exception de type SAXParseException signifie que c'est du côté de la configuration XML (il doit s'appeler hibernate.cfg.xml ou persistence.xml) qu'il faut chercher. Le fichier semble incorrect est donc Hibernate ne peut pas charger la configuration et le mapping.

    Peux-tu montrer le contenu de ce fichier ?

  3. #3
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    oui, voici mon fichier persistance.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
     
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence>
      <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
       <class>ModeleMD.Produit</class>
       <class>ModeleMD.Catalogue</class>
        <properties>
          <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
          <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
          <property name="hibernate.connection.username" value="postgres"/>
          <property name="hibernate.connection.password" value="postgres"/>
          <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/jpadb"/>
          <property name="hibernate.max_fetch_depth" value="3"/>
          <!-- création du schéma automatiquement -->
          <--
          <property name="hibernate.hbm2ddl.auto" value="create"/>
          -->
        </properties>
      </persistence-unit>
    </persistence>

  4. #4
    Membre actif Avatar de mOuLi
    Homme Profil pro
    Développeur Java
    Inscrit en
    Avril 2008
    Messages
    170
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Développeur Java

    Informations forums :
    Inscription : Avril 2008
    Messages : 170
    Points : 257
    Points
    257
    Par défaut
    Si tu es en UTF-8, tu ne peux pas avoir de caractères accentués. Remplace les 'é' par 'e' et essaye à nouveau.

  5. #5
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Citation Envoyé par mouss4rs Voir le message
    oui, voici mon fichier persistance.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
    <?xml version="1.0" encoding="UTF-8"?>
    <persistence>
      <persistence-unit name="manager1" transaction-type="RESOURCE_LOCAL">
       <class>ModeleMD.Produit</class>
       <class>ModeleMD.Catalogue</class>
        <properties>
          <property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
          <property name="hibernate.connection.driver_class" value="org.postgresql.Driver"/>
          <property name="hibernate.connection.username" value="postgres"/>
          <property name="hibernate.connection.password" value="postgres"/>
          <property name="hibernate.connection.url" value="jdbc:postgresql://localhost/jpadb"/>
          <property name="hibernate.max_fetch_depth" value="3"/>
          <!-- création du schéma automatiquement -->
          <--
          <property name="hibernate.hbm2ddl.auto" value="create"/>
          -->
        </properties>
      </persistence-unit>
    </persistence>
    N'aurais tu pas oublié un ! sur la ligne en rouge (ton commentaire ouvrant est mal formé)?
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  6. #6
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    bien joué sinok !
    on reconnait l'expert
    j'avoue que j'aurai plus galèrer un max.

    un grand merci

  7. #7
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    Encore une chose :
    j'ai toujours ce message d'erreur et je ne vois pas d'ou cela vient malgré que ca marche:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    log4j:WARN No appenders could be found for logger (org.hibernate.cfg.annotations.Version).
    log4j:WARN Please initialize the log4j system properly.
    j'aimerai bien savoir s'il ya un remede ?

    merci sinon résolu!

  8. #8
    Expert éminent sénior
    Avatar de sinok
    Profil pro
    Inscrit en
    Août 2004
    Messages
    8 765
    Détails du profil
    Informations personnelles :
    Âge : 43
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Août 2004
    Messages : 8 765
    Points : 12 977
    Points
    12 977
    Par défaut
    Ce n'est pas un message d'erreur mais Log4j qui prévient qu'il ne trouve pas de fichier de configurations des logs.

    Plus d'infos sur Log4j: http://gfx.developpez.com/tutoriel/java/log4j/
    Hey, this is mine. That's mine. All this is mine. I'm claiming all this as mine. Except that bit. I don't want that bit. But all the rest of this is mine. Hey, this has been a really good day. I've eaten five times, I've slept six times, and I've made a lot of things mine. Tomorrow, I'm gonna see if I can't have sex with something.

  9. #9
    Membre averti Avatar de mouss4rs
    Profil pro
    Inscrit en
    Janvier 2008
    Messages
    884
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2008
    Messages : 884
    Points : 355
    Points
    355
    Par défaut
    merci

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

Discussions similaires

  1. mon projet ne veut plus compiler
    Par guitariste dans le forum C++
    Réponses: 25
    Dernier message: 10/04/2008, 16h45
  2. [2007] en Runtime l'insert ne marche plus, erreur 3346
    Par tAKAmAkA dans le forum Runtime
    Réponses: 7
    Dernier message: 04/12/2007, 16h57
  3. Mon projet n'accepte plus les modifications
    Par bache dans le forum VB.NET
    Réponses: 8
    Dernier message: 13/11/2007, 08h27
  4. Pourquoi mon projet ne compile plus ?
    Par piotrr dans le forum VB.NET
    Réponses: 7
    Dernier message: 26/09/2007, 21h02
  5. [Classloader]mon progr ne marche plus après modif des *.class
    Par Melchisedec dans le forum API standards et tierces
    Réponses: 16
    Dernier message: 30/04/2006, 20h48

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