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 :

BeanCreationException ? problème d'injection de dépendances [Framework]


Sujet :

Spring Java

  1. #1
    Membre du Club
    Inscrit en
    Décembre 2007
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 55
    Points : 45
    Points
    45
    Par défaut BeanCreationException ? problème d'injection de dépendances
    Bonjour.

    J'ai 2 projets java : TicketDao et TicketService, et un projet Grails TicketWeb.

    Quand je lance le serveur Tomcat depuis Eclipse (3.4) pour démarrer TicketWeb j'ai l'erreur suivant :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myTicketDao' defined in class path resource [services/spring-hibernate.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
    PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [org.hibernate.impl.SessionFactoryImpl] to required type [org.hibernate.SessionFactory] for property 'sessionFactory'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [org.hibernate.impl.SessionFactoryImpl] to required type [org.hibernate.SessionFactory] for property 'sessionFactory': no matching editors or conversion strategy found
    voila mon arborescence :
    + TicketDAO
    + hibernate
    -ITicketDao.java
    -TicketDao.java (implements ITicketDao)
    -Ticket.java (POJO)
    -ticket.hbm.xml

    + TicketService
    + services
    -Test.java
    -ITicketService.java
    -TicketService.java (implements ITicketService)
    -spring-hibernate.xml

    + TicketWeb
    +WEB-INF
    -applicationContext.xml (j'import ici spring-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
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd" >
    <beans>
     
    	<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    	    <property name="driverClassName" value="org.postgresql.Driver"/>
    	    <property name="url" value="jdbc:postgresql://localhost/formation"/>
    	    <property name="username" value="postgres"/>
    	    <property name="password" value="postgres"/>
    	</bean>
     
    	<bean id="mySessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    	    <property name="dataSource" ref="myDataSource"/>
    	    <property name="mappingResources">
    	        <list>
    	            <value>./hibernate/ticket.hbm.xml</value>
    	        </list>
    	    </property>
    	    <property name="hibernateProperties">
    	        <value>hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect</value>
    	    </property>
    	</bean>
     
    	<bean id="myHibernateTemplate" 
    			class="org.springframework.orm.hibernate3.HibernateTemplate">
    	    <property name="sessionFactory">
    	        <ref bean="mySessionFactory"/>
    	    </property>
    	</bean>
     
    	<bean id="myTicketDao" class="hibernate.TicketDao">
    	    <property name="hibernateTemplate">
    	        <ref bean="myHibernateTemplate"/>    
    	    </property>
    	</bean>
     
     	<bean id="myTicketService" class="services.TicketService">
    	    <property name="ticketDao">
    	        <ref bean="myTicketDao"/>    
    	    </property>
    	</bean>
    </beans>
    et mon 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
    55
    <?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-2.0.xsd">
     
     
    	<import resource="classpath:/services/spring-hibernate.xml"/>   
     
    	<bean id="grailsApplication"
    		class="org.codehaus.groovy.grails.commons.GrailsApplicationFactoryBean">
    		<description>Grails application factory bean</description>
    		<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
    		<property name="grailsResourceLoader" ref="grailsResourceLoader" />
    	</bean>
     
    	<bean id="pluginManager"
    		class="org.codehaus.groovy.grails.plugins.GrailsPluginManagerFactoryBean">
    		<description>A bean that manages Grails plugins</description>
    		<property name="grailsDescriptor" value="/WEB-INF/grails.xml" />
    		<property name="application" ref="grailsApplication" />
    	</bean>
     
    	<bean id="pluginMetaManager"
    		class="org.codehaus.groovy.grails.plugins.DefaultPluginMetaManager">
    		<constructor-arg value="classpath*:**/plugins/*/plugin.xml" />
    	</bean>
     
    	<bean id="grailsConfigurator"
    		class="org.codehaus.groovy.grails.commons.spring.GrailsRuntimeConfigurator">
    		<constructor-arg>
    			<ref bean="grailsApplication" />
    		</constructor-arg>
    		<property name="pluginManager" ref="pluginManager" />
    	</bean>
     
    	<bean id="grailsResourceLoader"
    		class="org.codehaus.groovy.grails.commons.GrailsResourceLoaderFactoryBean">
    		<property name="grailsResourceHolder" ref="grailsResourceHolder" />
    	</bean>
     
    	<bean id="grailsResourceHolder" scope="prototype"
    		class="org.codehaus.groovy.grails.commons.spring.GrailsResourceHolder">
    		<property name="resources">
    			<value>classpath*:**/grails-app/**/*.groovy
    			</value>
    		</property>
    	</bean>
     
    	<bean id="characterEncodingFilter" class="org.springframework.web.filter.CharacterEncodingFilter">
    		<property name="encoding">
    			<value>utf-8</value>
    		</property>
    	</bean>
    </beans>
    + Configuration:
    - Grails 1.0.1
    - Elicpse 3.4
    - hibernate 3
    - spring 2.5.1

    Je plante ici depuis 3 jours, veuillez poster vos suggestion

  2. #2
    Membre confirmé
    Profil pro
    Inscrit en
    Décembre 2003
    Messages
    476
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Décembre 2003
    Messages : 476
    Points : 595
    Points
    595
    Par défaut
    veuillez poster vos suggestion
    Ils flottent tous en bas

  3. #3
    Membre du Club
    Inscrit en
    Décembre 2007
    Messages
    55
    Détails du profil
    Informations forums :
    Inscription : Décembre 2007
    Messages : 55
    Points : 45
    Points
    45
    Par défaut
    Merci, ça m'a aidé enormement

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. [Framework] Problème injection de dépendance Spring + JSF
    Par wahhh dans le forum Spring
    Réponses: 1
    Dernier message: 02/04/2015, 23h56
  2. Problème avec injection de dépendances
    Par PascalCmoa dans le forum Services Web
    Réponses: 4
    Dernier message: 31/10/2013, 08h56
  3. Problème d'injection de dépendance ?
    Par oxman dans le forum Langage
    Réponses: 3
    Dernier message: 02/09/2010, 09h50
  4. [Integration] [EasyMock] Injection de dépendance à l'éxécution
    Par frangin2003 dans le forum Spring
    Réponses: 2
    Dernier message: 06/03/2007, 11h06
  5. Spring + TagSupport et injection de dépendance
    Par worldchampion57 dans le forum Spring Web
    Réponses: 2
    Dernier message: 26/02/2007, 09h01

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