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