title: Spring CrudRepository is null for @Autowired member variable
body: <p>I am new to Spring JPA. I am trying to use hibernate + Spring JPA. For this I created below repository</p>
  
  <pre><code>package com.raptorservice.da.dal;
  
  import com.raptorservice.da.objects.ClientDO;
  import org.springframework.data.repository.CrudRepository;
  
  public interface ClientRepository extends CrudRepository&lt;ClientDO, String&gt; {    
  }
  </code></pre>
  
  <p>Below is my spring-ws-servlet.xml where i browse through my packages.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:sws="http://www.springframework.org/schema/web-services"
      xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
      xmlns:jpa="http://www.springframework.org/schema/data/jpa"
      xsi:schemaLocation="http://www.springframework.org/schema/beans 
                          http://www.springframework.org/schema/beans/spring-beans.xsd 
                          http://www.springframework.org/schema/web-services 
                          http://www.springframework.org/schema/web-services/web-services.xsd 
                          http://www.springframework.org/schema/oxm 
                          http://www.springframework.org/schema/oxm/spring-oxm.xsd
                          http://www.springframework.org/schema/jdbc
                          http://www.springframework.org/schema/jdbc/spring-jdbc.xsd
                          http://www.springframework.org/schema/data/jpa
                          http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
                          "&gt;
  
      &lt;!--  ****************************** BASIC CONFIGURATION ******************************************** --&gt;
      &lt;!-- Enable annotations for end points --&gt;
      &lt;sws:annotation-driven /&gt;
  
  
      &lt;bean id="getpointsbean" class="com.raptorservice.endpoints.GetPointsEndpoint"&gt;
      &lt;/bean&gt;
  
      &lt;sws:dynamic-wsdl id="points" portTypeName="Points" locationUri="/points/" targetNamespace="http://sailin.com/schemas"&gt;
          &lt;sws:xsd location="/WEB-INF/xsd/points.xsd" /&gt;
      &lt;/sws:dynamic-wsdl&gt;
  
      &lt;!--  Configure JAXB to marshal and un-marshal requests --&gt;
      &lt;oxm:jaxb2-marshaller id="jaxbMarshaller"  contextPath="com.raptorservice.generated" /&gt;
  
  
  
      &lt;!-- ******************************* PERSISTANCE CONFIGURATION ****************************************** --&gt;
      &lt;!--  JPA Repositories --&gt;
  &lt;jpa:repositories  base-package="com.raptorservice.da.dal" /&gt; 
  
  
  
      &lt;!--  Hibernate Transaction Manager --&gt;
      &lt;bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"&gt;
          &lt;property name="sessionFactory" ref="sessionFactory" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
          destroy-method="close"&gt;
          &lt;property name="driverClassName" value="com.mysql.jdbc.Driver" /&gt;
          &lt;property name="url" value="jdbc:mysql://localhost:3306/testservice" /&gt;
          &lt;property name="username" value="root" /&gt;
          &lt;property name="password" value="admin" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
          &lt;property name="persistenceXmlLocation" value="./WEB-INF/persistence.xml"&gt;&lt;/property&gt;
          &lt;property name="jpaVendorAdapter"&gt;
              &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
                  &lt;property name="database" value="MYSQL" /&gt;
                  &lt;property name="showSql" value="true" /&gt;
              &lt;/bean&gt;
          &lt;/property&gt;
       &lt;/bean&gt;
  
  
      &lt;bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
          &lt;property name="dataSource" ref="dataSource" /&gt;
  &lt;!--        &lt;property name="configLocation"&gt; --&gt;
  &lt;!--            &lt;value&gt;classpath:hibernate.cfg.xml&lt;/value&gt; --&gt;
  &lt;!--        &lt;/property&gt; --&gt;
  &lt;!--        &lt;property name="configurationClass"&gt; --&gt;
  &lt;!--            &lt;value&gt;org.hibernate.cfg.AnnotationConfiguration&lt;/value&gt; --&gt;
  &lt;!--        &lt;/property&gt; --&gt;
          &lt;property name="hibernateProperties"&gt;
              &lt;props&gt;
                  &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQLDialect&lt;/prop&gt;
                  &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
              &lt;/props&gt;
          &lt;/property&gt;
      &lt;/bean&gt;
  
  
  
   &lt;/beans&gt;
  </code></pre>
  
  <p>I do have a valid persistence.xml file too under WEB-INF.</p>
  
  <p>I am trying to use the ClientRepository in my webservice (@Endpoint) as below</p>
  
  <pre><code>package com.raptorservice.endpoints;
  
  
  @Endpoint
  public class GetPointsEndpoint {    
  
      @Autowired
      private ClientRepository clientRepository;
  
  @PayloadRoot(localPart="getPointsForClientAndCustomerRequest", namespace="http://sailin.com/schemas")
      @ResponsePayload()
      public GetPointsForClientAndCustomerResponse getPointsForClientAndCustomerRequest(@RequestPayload GetPointsForClientAndCustomerRequest getpointsRequest) throws Exception
      {
          GetPointsForClientAndCustomerResponse resp = new GetPointsForClientAndCustomerResponse();
          ResultCode resCode = new ResultCode();
  
          try
          {
          ClientDO client = new ClientDO();
          client.setName("Test1");
          client.setClientId("test111");
          clientRepository.save(client);
          }
          catch(Exception ex)
          {
            System.out.println(ex);
          }
  
  
          resCode.setDescription("pass");
          resCode.setCode(BigInteger.valueOf(5));
          resp.setResultCode(resCode);
          return resp;
      }
  </code></pre>
  
  <p>But the clientRepository is always null. What am I missing? Why is clientRepository not being auto wired? </p>
  
  <p>I checked the logs and nothing obvious. Please help.</p>
  
  <p>Thanks in advance.</p>