title: No property index found for type User
body: <p>I'm trying to use ElasticSearch with MySQL in the same project.
  I defined two repositories in different project but I always get this error message:</p>
  
  <pre><code>Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userController': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.services.UserServices com.owish.controllers.UserController.userServices; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServices': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.repositories.search.UserSearchRepo com.owish.services.UserServices.userSearchRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
  at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
  at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:139)
  at org.springframework.context.support.ClassPathXmlApplicationContext.&lt;init&gt;(ClassPathXmlApplicationContext.java:83)
  at com.owish.services.AppServices.main(AppServices.java:25)
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.services.UserServices com.owish.controllers.UserController.userServices; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServices': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.repositories.search.UserSearchRepo com.owish.services.UserServices.userSearchRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
  ... 13 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userServices': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.repositories.search.UserSearchRepo com.owish.services.UserServices.userSearchRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
  ... 15 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private com.owish.repositories.search.UserSearchRepo com.owish.services.UserServices.userSearchRepo; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:573)
  at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
  ... 26 more
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userSearchRepo': Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
  at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
  at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
  at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
  at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
  at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
  at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
  ... 28 more
  Caused by: org.springframework.data.mapping.PropertyReferenceException: No property index found for type User!
  at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:77)
  at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:329)
  at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:309)
  at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:272)
  at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:243)
  at org.springframework.data.repository.query.parser.Part.&lt;init&gt;(Part.java:76)
  at org.springframework.data.repository.query.parser.PartTree$OrPart.&lt;init&gt;(PartTree.java:235)
  at org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:373)
  at org.springframework.data.repository.query.parser.PartTree$Predicate.&lt;init&gt;(PartTree.java:353)
  at org.springframework.data.repository.query.parser.PartTree.&lt;init&gt;(PartTree.java:84)
  at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:62)
  at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:100)
  at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:211)
  at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:74)
  at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:416)
  at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:206)
  at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.initAndReturn(RepositoryFactoryBeanSupport.java:251)
  at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:237)
  at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:92)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1637)
  at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1574)
  ... 38 more
  </code></pre>
  
  <p>When I was just using the <code>JpaRepository</code> I had no problem.
  I got that issue only when I added another repository that extends <code>ElasticsearchRepository</code>.
  the interface definition of JPA and Elastic search were defined in different packages.
  I'm using elastic search 2.2.1 with Spring data elasticsearch 1.3.4
  I think it's a configuration issue.
  below is the application config that I'm using. Would you tell me if I'm missing something:</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:jpa="http://www.springframework.org/schema/data/jpa"
  xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context"
  xmlns:elasticsearch="http://www.springframework.org/schema/data/elasticsearch"
  xsi:schemaLocation="http://www.springframework.org/schema/beans 
  http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/data/jpa 
  http://www.springframework.org/schema/data/jpa/spring-jpa.xsd
  http://www.springframework.org/schema/tx 
  http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
  http://www.springframework.org/schema/context 
  http://www.springframework.org/schema/context/spring-context-4.2.xsd
  http://www.springframework.org/schema/data/elasticsearch
  http://www.springframework.org/schema/data/elasticsearch/spring-elasticsearch-1.0.xsd"&gt;
  
  &lt;context:component-scan base-package="com.owish." /&gt;
  
  &lt;elasticsearch:node-client id="client" local="true" /&gt;
  &lt;elasticsearch:repositories base-package="com.owish.repositories.search" /&gt;
  &lt;elasticsearch:transport-client id="client"
      cluster-nodes="localhost:9200,someip:9200" /&gt;
  
  
  &lt;bean class="org.apache.commons.dbcp.BasicDataSource"
      destroy-method="close" id="dataSource"&gt;
      &lt;property name="driverClassName" value="com.mysql.jdbc.Driver"&gt;&lt;/property&gt;
      &lt;property name="url" value="jdbc:mysql://localhost:3306/owish"&gt;&lt;/property&gt;
      &lt;property name="username" value="root"&gt;&lt;/property&gt;
      &lt;property name="password" value="root"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;bean id="entityManagerFactory"
      class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource"&gt;&lt;/property&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="generateDdl" value="true"&gt;&lt;/property&gt;
              &lt;property name="database" value="MYSQL"&gt;&lt;/property&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="packagesToScan" value="com.owish.model" /&gt;
      &lt;property name="persistenceUnitName" value="jpa.sample"&gt;&lt;/property&gt;
  &lt;/bean&gt;
  &lt;!-- Configure the transaction manager bean --&gt;
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  
  &lt;jpa:repositories base-package="com.owish.repositories" /&gt;
  &lt;!-- Enable annotation driven transaction management --&gt;
  &lt;tx:annotation-driven /&gt;
  </code></pre>
  
  <p></p>
  
  <p>My user entity was declared like this:</p>
  
  <pre><code>@Entity
  @Table (name ="user")
  @Document(indexName = "user")
  public class User {
  
  @Id
  @Column (name = "id") 
  @GeneratedValue (strategy = GenerationType.AUTO)
  private long id;
  @Column (name = "username", nullable = false)
  private String username;
  @Column (name = "password", nullable = false)
  private String password;
  </code></pre>
  
  <p>and my ElasticSearch repo was defined like this:</p>
  
  <pre><code>@Repository
  public interface UserSearchRepo extends ElasticsearchRepository&lt;User, Long&gt; {
  User findByUsername(String username);
  List&lt;User&gt; findAllByOrderById ();
  }
  </code></pre>
  
  <p>and my JPA repo</p>
  
  <pre><code>@Repository
  public interface UserRepository extends JpaRepository&lt;User, Long&gt; {
  }
  </code></pre>