title: What is the cause of PropertyReferenceException
body: <p>I shared the models, repositories and controllers I have created below. The error message is attached. What is the cause of the <code>PropertyReferenceException</code>? What do I need to change?</p>
  
  <p>Player</p>
  
  <pre><code>@Entity
  @Table(name = "player")
  public class Player{
  
      @Id
      @GeneratedValue
      @NotNull
      @Column
      private int id;
  
      @NotNull
      @Column
      private String playerName;
  
      @NotNull
      @Column
      private String playerSurname;
  
      @Column
      private int playerAge;
  
  
  
      public String getPlayerName() {
          return playerName;
      }
  
      public void setPlayerName(String playerName) {
          this.playerName = playerName;
      }
  
      public String getPlayerSurname() {
          return playerSurname;
      }
  
      public void setPlayerSurname(String playerSurname) {
          this.playerSurname = playerSurname;
      }
  
      public int getId() {
          return id;
      }
  
      public void setId(int id) {
          this.id = id;
      }
  
      public int getPlayerAge() {
          return playerAge;
      }
  
      public void setPlayerAge(int playerAge) {
          this.playerAge = playerAge;
      }
  
      @OneToOne
      private Team team;
  
      public Team getTeam() {
          return team;
      }
  
      public void setTeam(Team team) {
          this.team = team;
      }
  
  
  }
  </code></pre>
  
  <p>Team</p>
  
  <pre><code>@Entity
  @Table(name = "team")
  public class Team {
  
      @Id
      @GeneratedValue
      @NotNull
      @Column
      private int id;
  
      @NotNull
      @Column
      private String teamName;
  
      @Column
      private String teamCountry;
  
      public Team(){
      }
  
      public int getTeamId() {
          return id;
      }
  
      public void setTeamId(int teamId) {
          this.id = teamId;
      }
  
      public String getTeamName() {
          return teamName;
      }
  
      public void setTeamName(String teamName) {
          this.teamName = teamName;
      }
  
      public String getTeamCountry() {
          return teamCountry;
      }
  
      public void setTeamCountry(String teamCountry) {
          this.teamCountry = teamCountry;
      }
  
  }
  </code></pre>
  
  <p>PlayerRepository</p>
  
  <pre><code>public interface PlayerRepository extends JpaRepository&lt;Player, Integer&gt;{
      List&lt;Player&gt; findPlayersByName(String playerName);
      List&lt;Player&gt; findPlayersBySurname(String playerSurname);
      List&lt;Player&gt; findPlayersByAge(int playerAge);
  
  }
  </code></pre>
  
  <p>TeamRepository</p>
  
  <pre><code>public interface TeamRepository extends JpaRepository&lt;Team, Integer&gt;{
      List&lt;Team&gt; findTeamsByName(String teamName);
      List&lt;Team&gt; findTeamsByCountry(String teamCountry);
  
  }
  </code></pre>
  
  <p>TeamController</p>
  
  <pre><code>@CrossOrigin(origins = "http://localhost:8000/")
  @RestController
  public class TeamController {
      @Autowired
      PlayerRepository playerRepository;
      @Autowired
      TeamRepository teamRepository;
  
      @RequestMapping("/")
      public void main() {
          //create teams by manual    
          Team barcelona = new Team();
          Team juventus = new Team();
          Team arsenal = new Team();
  
          barcelona.setTeamName("Barcelona");
          barcelona.setTeamCountry("Spain");
  
          juventus.setTeamName("Juventus");
          juventus.setTeamCountry("Italy");
  
          arsenal.setTeamName("Arsenal");
          arsenal.setTeamCountry("England");
  
          this.teamRepository.save(barcelona);
          this.teamRepository.save(juventus);
          this.teamRepository.save(arsenal);
  
  
          //create players by manual
          Player messi = new Player();
          Player ronaldo = new Player();
          Player ozil = new Player();
  
          messi.setPlayerName("Lionel");
          messi.setPlayerSurname("Messi");
          messi.setPlayerAge(31);
          messi.setTeam(barcelona);
  
          ronaldo.setPlayerName("Cristiano");
          ronaldo.setPlayerSurname("Ronaldo");
          ronaldo.setPlayerAge(32);
          ronaldo.setTeam(juventus);
  
          ozil.setPlayerName("Mesut");
          ozil.setPlayerSurname("Ozil");
          ozil.setPlayerAge(29);
          ozil.setTeam(arsenal);
  
          this.playerRepository.save(messi);
          this.playerRepository.save(ronaldo);
          this.playerRepository.save(ozil);
      }   
  
      //**PLAYER**
      @GetMapping(value="/getAllPLayers")
      public List&lt;Player&gt; getAllPlayers(){
          return playerRepository.findAll();
      }
  
      @PostMapping(value="getPlayerByName")
      public List&lt;Player&gt; getPlayerByName(@RequestParam("playerName") String playerName){
          return playerRepository.findPlayersByName(playerName);
      }
  
      @PostMapping(value="getPlayerBySurname")
      public List&lt;Player&gt; getPlayerBySurname(@RequestParam("playerSurname") String playerSurname){
          return playerRepository.findPlayersBySurname(playerSurname);
      }   
  
      @PostMapping(value="getPlayerByAge")
      public List&lt;Player&gt; getPlayerByAge(@RequestParam("playerAge") int playerAge){
          return playerRepository.findPlayersByAge(playerAge);
      }   
  
  
      //**TEAM**
      @GetMapping(value="/getAllTeams")
      public List&lt;Team&gt; getAllTeams(){
          return teamRepository.findAll();
      }
  
      @PostMapping(value = "/getTeamsByName")
      public List&lt;Team&gt; getTeamByName(@RequestParam("teamName") String teamName){
          return teamRepository.findTeamsByName(teamName);
      }
  
      @PostMapping(value = "/getTeamsByCountry")
      public List&lt;Team&gt; getTeamByCountry(@RequestParam("teamCountry") String teamCountry){
          return teamRepository.findTeamsByCountry(teamCountry);
      }
  }
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
  2019-07-29 14:01:22.391 ERROR 18540 --- [  restartedMain] o.s.boot.SpringApplication               : Application run failed
  
  org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'teamController': Unsatisfied dependency expressed through field 'playerRepository'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'playerRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.example.demo.repository.PlayerRepository.findPlayersBySurname(java.lang.String)! No property surname found for type Player!
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:596) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:90) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessProperties(AutowiredAnnotationBeanPostProcessor.java:374) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1411) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:592) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:845) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:877) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:549) ~[spring-context-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140) ~[spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:742) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:389) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:311) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1213) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1202) [spring-boot-2.1.6.RELEASE.jar:2.1.6.RELEASE]
      at com.example.demo.FmanagementApplication.main(FmanagementApplication.java:10) [classes/:na]
      at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_221]
      at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_221]
      at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_221]
      at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49) [spring-boot-devtools-2.1.6.RELEASE.jar:2.1.6.RELEASE]
  Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'playerRepository': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.example.demo.repository.PlayerRepository.findPlayersBySurname(java.lang.String)! No property surname found for type Player!
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1778) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:593) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:515) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:320) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:318) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.config.DependencyDescriptor.resolveCandidate(DependencyDescriptor.java:277) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1251) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1171) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:593) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      ... 24 common frames omitted
  Caused by: java.lang.IllegalArgumentException: Failed to create query for method public abstract java.util.List com.example.demo.repository.PlayerRepository.findPlayersBySurname(java.lang.String)! No property surname found for type Player!
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:84) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:106) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:211) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:79) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lookupQuery(RepositoryFactorySupport.java:566) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$mapMethodsToQuery$1(RepositoryFactorySupport.java:559) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_221]
      at java.util.Iterator.forEachRemaining(Unknown Source) ~[na:1.8.0_221]
      at java.util.Collections$UnmodifiableCollection$1.forEachRemaining(Unknown Source) ~[na:1.8.0_221]
      at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.mapMethodsToQuery(RepositoryFactorySupport.java:561) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.lambda$new$0(RepositoryFactorySupport.java:551) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.Optional.map(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:551) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:324) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.lambda$afterPropertiesSet$5(RepositoryFactoryBeanSupport.java:297) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.util.Lazy.getNullable(Lazy.java:211) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.util.Lazy.get(Lazy.java:94) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.afterPropertiesSet(RepositoryFactoryBeanSupport.java:300) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet(JpaRepositoryFactoryBean.java:121) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1837) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1774) ~[spring-beans-5.1.8.RELEASE.jar:5.1.8.RELEASE]
      ... 34 common frames omitted
  Caused by: org.springframework.data.mapping.PropertyReferenceException: No property surname found for type Player!
      at org.springframework.data.mapping.PropertyPath.&lt;init&gt;(PropertyPath.java:94) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:382) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:358) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.mapping.PropertyPath.lambda$from$0(PropertyPath.java:311) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.concurrent.ConcurrentMap.computeIfAbsent(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:293) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:276) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.query.parser.Part.&lt;init&gt;(Part.java:81) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.query.parser.PartTree$OrPart.lambda$new$0(PartTree.java:250) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[na:1.8.0_221]
      at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.data.repository.query.parser.PartTree$OrPart.&lt;init&gt;(PartTree.java:251) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.query.parser.PartTree$Predicate.lambda$new$0(PartTree.java:380) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReferencePipeline$2$1.accept(Unknown Source) ~[na:1.8.0_221]
      at java.util.Spliterators$ArraySpliterator.forEachRemaining(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.copyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.AbstractPipeline.evaluate(Unknown Source) ~[na:1.8.0_221]
      at java.util.stream.ReferencePipeline.collect(Unknown Source) ~[na:1.8.0_221]
      at org.springframework.data.repository.query.parser.PartTree$Predicate.&lt;init&gt;(PartTree.java:381) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.repository.query.parser.PartTree.&lt;init&gt;(PartTree.java:96) ~[spring-data-commons-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:78) ~[spring-data-jpa-2.1.9.RELEASE.jar:2.1.9.RELEASE]
      ... 60 common frames omitted
  </code></pre>