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

Spring Java Discussion :

Erreur "No persistence unit found"


Sujet :

Spring Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 3
    Par défaut Erreur "No persistence unit found"
    Bonjour je développe une application avec JPA(Eclipselink)/Spring/jsf et j'ai un problème dans la configuration de JPA avec Sping voila l'erreur qui me sort :
    Exception while loading the app : java.lang.IllegalStateException: ContainerBase.addChild: start: org.apache.catalina.LifecycleException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: No persistence unit with name 'RimPU' found
    Voilà mon implémentation :
    Mon fichier applicationContext.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
    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
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:aop="http://www.springframework.org/schema/aop"
           xmlns:context="http://www.springframework.org/schema/context"
           xmlns:flow="http://www.springframework.org/schema/webflow-config"
           xmlns:jms="http://www.springframework.org/schema/jms"
           xmlns:jee="http://www.springframework.org/schema/jee"
           xmlns:lang="http://www.springframework.org/schema/lang"
           xmlns:osgi="http://www.springframework.org/schema/osgi"
           xmlns:tx="http://www.springframework.org/schema/tx"
           xmlns:util="http://www.springframework.org/schema/util"
           xmlns:p="http://www.springframework.org/schema/p"
     
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
              http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/webflow-config http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.0.xsd
              http://www.springframework.org/schema/jms http://www.springframework.org/schema/jms/spring-jms-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/osgi http://www.springframework.org/schema/osgi/spring-osgi-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.6.SEC01.xsd
              http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.5.6.SEC01.xsd
    ">
     
      <bean id="applicationContextHolder"	class="Dao.ApplicationContextHolder" />
     
     
       <bean id="entityManagerFactory"
    		class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"
    		p:persistenceXmlLocation="classpath*:/WEB-INF/persistence.xml"
    		p:persistenceUnitName="RimPU" p:dataSource-ref="dataSource"
    		p:jpaVendorAdapter-ref="jpaVendor" />
     
    <bean id="jpaVendor" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter " />
     <bean id="jpaAdapter" class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
       <property name="databasePlatform" value="org.eclipse.persistence.platform.database.OraclePlatform" />
       <property name="showSql" value="true" />
    </bean>
     
       <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
            <property name="driverClassName" value="oracle.jdbc.OracleDriver" />
            <property name="url" value="jdbc:oracle:thin:@localhost:1521:XE" />
            <property name="username" value="rim" />
            <property name="password" value="rim" />
        </bean>
        <bean id="RubriqueDAO" class="Dao.RubriqueDAO">
     
      </bean>
     
     
     
    </beans>
    Mon fichier persistence.xml:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    <?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="RimPU" transaction-type="RESOURCE_LOCAL">
     
        <exclude-unlisted-classes>true</exclude-unlisted-classes>
     
      </persistence-unit>
    </persistence>
    Ma classe RubriqueDAO
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    public class RubriqueDAO extends JpaDaoSupport implements ApplicationContextAware{
     
     
        public RubriqueDAO() {
        }
          public void save(Rubrique restaurant) {
            getJpaTemplate().persist(restaurant);
      }
    Ma classe Main:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     Rubrique r=new Rubrique();
              r.setCode("112");
              RubriqueDAO r1=new RubriqueDAO();
     
              r1.save(r);
    Merci pour votre aide

  2. #2
    Membre Expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2004
    Messages
    1 184
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

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

    Informations forums :
    Inscription : Avril 2004
    Messages : 1 184
    Par défaut
    Bonjour,

    Où se trouve ton fichier persistence.xml ?
    Dans un war il doit être dans WEB-INF/classes/META-INF/, et dans un jar, directement dans META-INF/

  3. #3
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 3
    Par défaut
    Merci pour votre réponse
    mon application est .war et il est crée automatiquement et il est placé dans un package nome "fichier de configuration" d'après mes recherches j'ai constaté qu'il doit être placé dans WEB-INF ce qui fait j'ai copié ce fichier dans ce package.
    Est-ce que j'ai fait est juste???si non qu'est ce que je dois faire???

  4. #4
    Candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Juillet 2012
    Messages
    3
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2012
    Messages : 3
    Par défaut
    Sachant que je développe avec Netbeans

Discussions similaires

  1. Persistence unit not found: 'null'.
    Par yLaplace dans le forum JPA
    Réponses: 0
    Dernier message: 24/07/2009, 16h27
  2. Erreur:There is no default persistence unit in this deployment.
    Par bmohcine dans le forum Wildfly/JBoss
    Réponses: 2
    Dernier message: 07/09/2007, 16h40
  3. nettoyer les persistence units
    Par toomsounet dans le forum NetBeans
    Réponses: 1
    Dernier message: 11/03/2007, 14h10
  4. [JBoss 4][EJB3] persistance.units NOTYETINSTALLED
    Par Zero dans le forum Wildfly/JBoss
    Réponses: 4
    Dernier message: 01/02/2007, 09h26

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