title: Cannot resolve reference to bean 'dataSource' Spring3 + Struts 2
body: <p>I'm trying to manage the login system from spring with a Database, I have created my database following this tutorial: <a href="http://www.mkyong.com/spring/maven-spring-jdbc-example/" rel="nofollow">http://www.mkyong.com/spring/maven-spring-jdbc-example/</a></p>
  
  <p>And i have created a <strong>datasource.xml</strong> file with this content:</p>
  
  <pre><code>&lt;beans xsi:schemaLocation="http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"&gt;
  
      &lt;bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"/&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/login"/&gt;
          &lt;property name="username" value="root"/&gt;
          &lt;property name="password" value="pass"/&gt;
      &lt;/bean&gt;
  
  &lt;/beans&gt;
  </code></pre>
  
  <p>and this is my security.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  
  &lt;!--
    - Configuracion de Muestra
    -
    --&gt;
  
  &lt;beans:beans xmlns="http://www.springframework.org/schema/security"
  xmlns:beans="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
                  http://www.springframework.org/schema/security 
                  http://www.springframework.org/schema/security/spring-security-3.1.xsd"&gt;
  
  &lt;beans:bean class="org.springframework.security.web.access.expression.DefaultWebSecurityExpressionHandler"/&gt;
  
        &lt;http auto-config='true'&gt;
  
      &lt;intercept-url pattern="/**" access="ROLE_USER" /&gt;
      &lt;form-login default-target-url='/example/index.jsp'
              always-use-default-target='true' /&gt;
      &lt;/http&gt;
  
    &lt;authentication-manager&gt;
         &lt;authentication-provider&gt;
          &lt;jdbc-user-service data-source-ref="dataSource"
  
             users-by-username-query="
                select nombre,password 
                from usuarios where username=?" 
  
             authorities-by-username-query="
                select u.nombre, ur.rol from usuarios u, usuarios_roles ur 
                where u.user_id = ur.user_id and u.username =?  " 
  
          /&gt;
         &lt;/authentication-provider&gt;
      &lt;/authentication-manager&gt;
  
  &lt;/beans:beans&gt;
  </code></pre>
  
  <p>But I'm having the next error on deploy:</p>
  
  <blockquote>
    <p>Cannot resolve reference to bean 'dataSource' while setting bean
    property 'dataSource'; nested exception is
    org.springframework.beans.factory.NoSuchBeanDefinitionException: No
    bean named 'dataSource' is defined</p>
  </blockquote>
  
  <p>I don't have idea what is wrong :(</p>