hi,

mon problème : je ne peux pas avoir l'injection de l'entityManager avec l'annotation suivante : @PersistenceContext(unitName="orm1").

voici mon fichier de beans:

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
 
<?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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
		http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
 
	<tx:annotation-driven/>
 
	<bean name="PersonneDao" class="dao.PersonneDao"></bean>
 
	<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"></bean>
 
 
 
 
 
</beans>
et voici 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
 
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="1.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_1_0.xsd">
	<persistence-unit name="orm1" transaction-type="RESOURCE_LOCAL" >
		<properties>
			<property name="hibernate.connection.username" value="root"/>
      		<property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/>
      		<property name="hibernate.connection.password" value="password"/>
      		<property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jbossdb"/>
      		<property name="hibernate.cache.provider_class" value="org.hibernate.cache.NoCacheProvider"/>
      		<property name="hibernate.hbm2ddl.auto" value="create-drop"/>
		</properties>
	</persistence-unit>
</persistence>
je ne suis pas sûr de ce qui concerne l'unité de persistance "orm1", si je m'y suis bien pris.
peut-être qu'il manque le jar contenant la classe
org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessest présent.
l' erreur c'est que ma variable em de type EntityManager reste désespérement à null.

merci,

olivier.