Bonjour,


Voila je suis débutant en Struts et j'ai quelques petit soucis pour lancer une petite application de test qui sert juste a créer un utilisateur en BDD afin d'apprendre les rudiements de Struts et le stockage en base via Hibernate le tout sous Tomcat 5.5.
Pour cela je suis entrain de lire le livre Spring par la pratique dont je me suis inspiré pour me faire mon propre exemple

Je n'ai pas completement terminé l'application, il me reste reste la partie jsp formulaire à coder.

Mon application contient :

- Un bean User avec getter et setter pour chaque propriétées
- Une interface UserManager contenant les méthodes du bean User
- Une classe UserManagerImpl implementant UserManager avec une méthode createUser.
- Une interface UserDAO contenant les méthodes d'insertion en base.
- Une classe UserDAOHibernate implementant cette derniere interface et utilisant org.springframework.orm.hibernate3.support.HibernateDaoSupport afin de passer par l'implementation hibernate de spring.


L'erreur se situe au lancement le serveur Tomcat me sort l'erreur suivante :

ERROR org.springframework.web.context.ContextLoader - Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'userDAO' of bean class [com.testspring.service.impl.UserManagerImpl]: Bean property 'userDAO' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?...

Voici mon fichier web.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
55
56
57
58
59
60
61
62
63
64
65
66
 
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
	<display-name>SpringTest</display-name>
 
	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/applicationContext*.xml</param-value>
	</context-param>
 
	<filter>
		<filter-name>Spring character encoding filter</filter-name>
		<filter-class>
			org.springframework.web.filter.CharacterEncodingFilter
		</filter-class>
		<init-param>
			<param-name>encoding</param-name>
			<param-value>UTF-8</param-value>
		</init-param>
		<init-param>
			<param-name>forceEncoding</param-name>
			<param-value>true</param-value>
		</init-param>
	</filter>
 
	<filter>
		<filter-name>Hibernate Session In View Filter</filter-name>
		<filter-class>
			org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
		</filter-class>
	</filter>
 
	<filter-mapping>
		<filter-name>Spring character encoding filter</filter-name>
		<url-pattern>/*</url-pattern>
	</filter-mapping>
 
	<filter-mapping>
		<filter-name>Hibernate Session In View Filter</filter-name>
		<url-pattern>*.action</url-pattern>
	</filter-mapping>
 
	<listener>
		<listener-class>
			org.springframework.web.context.ContextLoaderListener
		</listener-class>
	</listener>
 
 
 
	<servlet>
 		<servlet-name>action</servlet-name>
 		<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
   		<init-param>
     		<param-name>config</param-name>
     		<param-value>/WEB-INF/struts-config.xml</param-value>
   		</init-param>
   		<load-on-startup>1</load-on-startup>
	</servlet>
 
	<servlet-mapping>
    	<servlet-name>action</servlet-name>
    	<url-pattern>*.action</url-pattern>
  	</servlet-mapping>
 
</web-app>

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
 
<?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:tx="http://www.springframework.org/schema/tx"
	xsi:schemaLocation="
      http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
	  http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
	  http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
 
	<bean id="userManager" class="com.testspring.service.impl.UserManagerImpl">
		<property name="userDAO">
			<ref bean="userDAO" />
		</property>
	</bean>
 
	<aop:config>
		<aop:advisor
			pointcut="execution(* com.testspring.service.UserManager.*(..))"
			advice-ref="txUserManager" />
	</aop:config>
 
	<tx:advice id="txUserManager">
		<tx:attributes>
			<tx:method name="create*" propagation="REQUIRED" />
			<tx:method name="update*" propagation="REQUIRED" />
			<tx:method name="delete*" propagation="REQUIRED" />
			<tx:method name="*" propagation="REQUIRED" read-only="true" />
		</tx:attributes>
	</tx:advice>	
 
</beans>
Mon fichier applicationContext-hibernate.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
 
<?xml version="1.0" encoding="UTF-8"?>
 
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
 
	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 
		<property name="configLocation">
			<value>classpath:hibernate.cfg.xml</value>
		</property>
	</bean>
 
	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
 
	<bean id="userDAO"
		class="com.testspring.domain.dao.hibernate3.UserDAOHibernate">
		<property name="sessionFactory">
			<ref bean="sessionFactory" />
		</property>
	</bean>
</beans>

Pour finir mon fichier hibernate.cfg.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
 
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
        "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
		"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
	<session-factory>
		<!-- datasource connection properties -->
		<property name="connection.datasource">java:comp/env/jdbc/SpringTest</property>
 
		<!-- dialect for MySQL -->
		<property name="dialect">
			org.hibernate.dialect.MySQLDialect
		</property>
 
        <property name="hibernate.cache.provider_class">
			org.hibernate.cache.EhCacheProvider
		</property>
 
		<property name="hibernate.cache.use_query_cache">true</property>
		<property name="hibernate.show_sql">false</property>
		<property name="hibernate.transaction.factory_class">
			org.hibernate.transaction.JDBCTransactionFactory
		</property>
 
 
		<!-- mapping files -->
		<mapping resource="com/testspring/domain/model/User.hbm.xml"/>
 
	</session-factory>
</hibernate-configuration>
Tout est normalement ok au niveau de la connection à la BDD MySQL je n'ai plus d'erreur le contexte est normalement correctement configuré.

Mais voila l'erreur citée plus haut m'empeche de démarrer, je pense avoir importer tout les librairies nécessaires.
J'utilise Spring 2.0.2.



Si qqun à une idée je suis preneur car là je vois pas trop et toutes mes recherches ce sont soldées par un échec...

Merci d'avance