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

JPA Java Discussion :

Unable to configure EntityManagerFactory


Sujet :

JPA Java

  1. #1
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    116
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 116
    Points : 40
    Points
    40
    Par défaut Unable to configure EntityManagerFactory
    Bonjour,

    je n'arrive pas à corriger cette erreur qui à l'air assez fréquente sur les forums.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named poc-gui-jpa: Provider named org.hibernate.ejb.HibernatePersistence threw unexpected exception at create EntityManagerFactory: 
    javax.persistence.PersistenceException
    javax.persistence.PersistenceException: [PersistenceUnit: poc-gui-jpa] Unable to configure EntityManagerFactory
    	at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:374)
    	at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:110)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    voici mon fichier persistence.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 version="2.0"
    	xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
    	<persistence-unit name="poc-gui-jpa" transaction-type="RESOURCE_LOCAL">
    		<provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
    		<class>jpa.Animal</class>
    		<properties>
    			<property name="eclipselink.target-database" value="PostgreSQL" />
    			<property name="javax.persistence.jdbc.url" value="jdbc:postgresql://localhost:5432/morpho" />
    			<property name="javax.persistence.jdbc.driver" value="org.postgresql.Driver" />
    			<property name="javax.persistence.jdbc.user" value="postgres" />
    			<property name="javax.persistence.jdbc.password" value="facil123$" />
    			<property name="eclipselink.ddl-generation" value="create-tables" />
    			<property name="eclipselink.ddl-generation.output-mode"
    				value="database" />
    			<property name="eclipselink.logging.level" value="INFO" />
    		</properties>
    	</persistence-unit>
    </persistence>
    J'ai l'impression qu'il n'arrive pas à trouver mon persistence-unit.

    Pourriez vous m'indiquer mon erreur?

    Merci,
    Images attachées Images attachées  

  2. #2
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Peut on voir la trace complète jusqu'au "caused by" ?
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  3. #3
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    116
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 116
    Points : 40
    Points
    40
    Par défaut
    biensur

    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
    -------------------------------------------------------------------------------
    Test set: jpa.AnimalTest
    -------------------------------------------------------------------------------
    Tests run: 1, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.328 sec <<< FAILURE!
    test(jpa.AnimalTest)  Time elapsed: 0.312 sec  <<< ERROR!
    javax.persistence.PersistenceException: No Persistence provider for EntityManager named poc-gui-jpa:  The following providers:
    org.hibernate.ejb.HibernatePersistence
    Returned null to createEntityManagerFactory.
     
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    	at jpa.AnimalTest.test(AnimalTest.java:18)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
    	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
    	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
    	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
    	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
    	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
    	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
    	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
    	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
    	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
    	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
    	at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
    	at org.apache.maven.surefire.junit4.JUnit4TestSet.execute(JUnit4TestSet.java:62)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.executeTestSet(AbstractDirectoryTestSuite.java:140)
    	at org.apache.maven.surefire.suite.AbstractDirectoryTestSuite.execute(AbstractDirectoryTestSuite.java:127)
    	at org.apache.maven.surefire.Surefire.run(Surefire.java:177)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.apache.maven.surefire.booter.SurefireBooter.runSuitesInProcess(SurefireBooter.java:345)
    	at org.apache.maven.surefire.booter.SurefireBooter.main(SurefireBooter.java:1009)
    Avez-vous besoin d'autre information?

    Je trouve bizare qu'il me dise
    The following providers:
    org.hibernate.ejb.HibernatePersistence
    alors que j'ai déclaré comme provider
    <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>

  4. #4
    Membre du Club
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    116
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Avril 2003
    Messages : 116
    Points : 40
    Points
    40
    Par défaut
    Si je me fais une class main

    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
    package jpa;
    import javax.persistence.*;
     
    public class Main {
     
        /**
         * @param args
         */
        public static void main(String[] args) {
            Animal animal = new Animal();
            // Obtention d’un gestionnaire d’entités et d’une transaction
            EntityManagerFactory emf =
            Persistence.createEntityManagerFactory("poc-gui-jpa");
            EntityManager em = emf.createEntityManager();
            EntityTransaction tx = em.getTransaction();
            // Stocke l'animal dans la classe
            tx.begin();
            em.persist(animal);
            tx.commit();
            em.close();
            emf.close();
     
        }
     
    }
    J'ai cette erreur :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    Exception in thread "main" javax.persistence.PersistenceException: No Persistence provider for EntityManager named poc-gui-jpa:  The following providers:
    org.hibernate.ejb.HibernatePersistence
    Returned null to createEntityManagerFactory.
     
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:154)
    	at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:83)
    	at jpa.Main.main(Main.java:12)

  5. #5
    Modérateur
    Avatar de paissad
    Homme Profil pro
    Ingénieur de développement (Java/JEE/Eclipse RCP,EMF & webMethods)
    Inscrit en
    Avril 2006
    Messages
    1 043
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 38
    Localisation : France, Haute Garonne (Midi Pyrénées)

    Informations professionnelles :
    Activité : Ingénieur de développement (Java/JEE/Eclipse RCP,EMF & webMethods)
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2006
    Messages : 1 043
    Points : 2 560
    Points
    2 560
    Par défaut
    Bonjour,
    montre ton pom.xml s'il te plaît, merci.

    Cordialement
    Nous n'héritons pas de la terre de nos parents, nous l'empruntons à nos enfants.
    Le chat du site est aussi ici pour aider. Ne pas hésiter à visiter !

  6. #6
    Membre éprouvé

    Homme Profil pro
    Architecte technique
    Inscrit en
    Juin 2005
    Messages
    588
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Essonne (Île de France)

    Informations professionnelles :
    Activité : Architecte technique
    Secteur : High Tech - Opérateur de télécommunications

    Informations forums :
    Inscription : Juin 2005
    Messages : 588
    Points : 1 230
    Points
    1 230
    Par défaut
    JE vois que tu as plusieurs persistence.xml... Que contient le persistence.xml de ton dossier de test ?

    Vas aussi voir dans le dossier target pour voir si ton persistence.xml est bien déployé.

    a+
    Philippe

Discussions similaires

  1. Unable to build EntityManagerFactory
    Par zg2pro dans le forum JPA
    Réponses: 4
    Dernier message: 08/10/2012, 16h56
  2. Unable to build EntityManagerFactory
    Par DevServlet dans le forum JPA
    Réponses: 7
    Dernier message: 05/06/2012, 17h33
  3. "Unable to configure Entity Manager"
    Par GiZeus dans le forum JPA
    Réponses: 11
    Dernier message: 25/05/2011, 18h36
  4. [Data] Unable to build EntityManagerFactory
    Par DevServlet dans le forum Spring
    Réponses: 1
    Dernier message: 12/05/2010, 15h04
  5. Unable to build EntityManagerFactory
    Par elmander dans le forum Persistance des données
    Réponses: 2
    Dernier message: 25/02/2010, 22h42

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