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 Web Java Discussion :

servlet.xml erreur de définition de bean [MVC]


Sujet :

Spring Web Java

  1. #1
    Membre habitué

    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    639
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 639
    Points : 167
    Points
    167
    Par défaut servlet.xml erreur de définition de bean
    Bonjour,

    Je développe une applciation Spring MVC/Hibernate/Mysql

    Au démarrage de Tomcat j'ai cette erreur :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ERROR: org.springframework.web.servlet.DispatcherServlet - Context initialization failed
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Cannot resolve reference to bean 'idDataSource' while setting bean property 'dataSource'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'idDataSource' defined in ServletContext resource [/WEB-INF/spring/appServlet/servlet-context.xml]: Instantiation of bean failed; nested exception is java.lang.IllegalStateException: No bean class specified on bean definition
    Il ne trouve pas le bean référencé idDataSource, mais j'ai pourtant bien défini idDataSource comme bean (cf code ci dessous).
    Savez vous pourquoi j'ai cette erreur?
    Merci d'avance.


    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:beans xmlns="http://www.springframework.org/schema/mvc"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:beans="http://www.springframework.org/schema/beans"
    	xsi:schemaLocation="
            http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
            http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
     
    	<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
     
    	<!-- Enables the Spring MVC @Controller programming model -->
    	<annotation-driven />
     
    	<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
    	<resources mapping="/resources/**" location="/resources/" />
     
    	<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
    	<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    		<beans:property name="prefix" value="/WEB-INF/views/" />
    		<beans:property name="suffix" value=".jsp" />
    	</beans:bean>
     
    	<!-- Imports user-defined @Controller beans that process client requests -->
    	<beans:import resource="controllers.xml" />
     
     
    	<beans:bean id="sessionFactory" 
    		class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
     
     
    	    <beans:property name="dataSource" ref="idDataSource"/>
     
    	    <beans:property name="hibernateProperties">
    	       <beans:props>
    	         <beans:prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</beans:prop>
    	         <beans:prop key="hibernate.show_sql">true</beans:prop>
    	       </beans:props>
    	    </beans:property>
     
    	    <beans:property name="annotatedClasses">
    		<beans:list>
    			<beans:value>com.thomas.tutorial</beans:value>
    		</beans:list>
    	    </beans:property>
     
        </beans:bean>
     
    	<beans:bean id="idDataSource">
    		<beans:property name="jdbc.driverClassName" value="com.mysql.jdbc.Driver"></beans:property>
    		<beans:property name="jdbc.url" value="jdbc:mysql://localhost:3306/devis"></beans:property>
    		<beans:property name="jdbc.username" value="root"></beans:property>
    		<beans:property name="jdbc.password" value="root"></beans:property>
    	</beans:bean>
    </beans:beans>

  2. #2
    Membre habitué

    Profil pro
    Inscrit en
    Juillet 2004
    Messages
    639
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juillet 2004
    Messages : 639
    Points : 167
    Points
    167
    Par défaut
    Forcément c'est en rédigeant ce message que j'ai trouvé l'erreur...

    Le bean idDataSource était mal déclaré :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    	<beans:bean id="idDataSource"  class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    		<beans:property name="driverClassName" value="com.mysql.jdbc.Driver"></beans:property>
    		<beans:property name="url" value="jdbc:mysql://localhost:3306/devis"></beans:property>
    		<beans:property name="username" value="root"></beans:property>
    		<beans:property name="password" value="root"></beans:property>
    	</beans:bean>

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

Discussions similaires

  1. Réponses: 5
    Dernier message: 27/07/2006, 08h05
  2. [Débutant][servlet]XML et servlet
    Par Sylario dans le forum Servlets/JSP
    Réponses: 1
    Dernier message: 19/04/2006, 10h16
  3. [servlet][xml] Erreur de parsing
    Par james2001 dans le forum Servlets/JSP
    Réponses: 26
    Dernier message: 03/11/2005, 07h08
  4. [XSL] Parser fichier xml : erreurs + incompréhensions
    Par totobouchon dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 19/07/2005, 15h47
  5. [Servlet][Compilation] Erreur de compil dans code servlet
    Par gandalf_le_blanc dans le forum Servlets/JSP
    Réponses: 3
    Dernier message: 13/05/2004, 10h17

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