title: java.util.NoSuchElementException creating Spring Data JPA repository bean
body: <p>My dependencies are:</p>
  
  <p>springVersion = '3.2.4.RELEASE'</p>
  
  <pre><code>compile "org.springframework:spring-***:$springVersion"
  *** = all of them are included just in case!
  compile "org.springframework.data:spring-data-jpa:1.4.1.RELEASE"
  compile "org.hibernate.javax.persistence:hibernate-jpa-2.0-api:1.0.1.Final"
  runtime "org.hibernate:hibernate-entitymanager:4.2.6.Final"
  testCompile "org.springframework:spring-test:$springVersion"
  runtime "com.h2database:h2:1.3.173"
  </code></pre>
  
  <p>I have the following context file:</p>
  
  <pre><code>&lt;tx:annotation-driven /&gt;
  
  &lt;jpa:repositories base-package="au.com.data3.samples.user.priv" /&gt;
  
  &lt;jdbc:embedded-database id="dataSource" type="H2"&gt;
  &lt;/jdbc:embedded-database&gt;
  
  &lt;bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan" value="au.com.data3.samples.user.model" /&gt;
      &lt;property name="jpaVendorAdapter"&gt;
          &lt;bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter"&gt;
              &lt;property name="showSql" value="false" /&gt;
              &lt;property name="generateDdl" value="true" /&gt;
              &lt;property name="database" value="H2" /&gt;
          &lt;/bean&gt;
      &lt;/property&gt;
      &lt;property name="jpaProperties"&gt;
          &lt;props&gt;
              &lt;!--&lt;prop key="hibernate.max_fetch_depth"&gt;&lt;/prop&gt;--&gt;
              &lt;prop key="hibernate.hbm2ddl.auto"&gt;create-drop&lt;/prop&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.H2Dialect&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager"&gt;
      &lt;property name="entityManagerFactory" ref="entityManagerFactory" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>I have my Repository class in the ....user.priv package:</p>
  
  <pre><code>public interface D3UserRepository extends JpaRepository&lt;D3User, Long&gt; {
  
  D3User findByUsername(String username);
      List&lt;D3User&gt; findByFirstName(String firstName);
      List&lt;D3User&gt; findByLastName(String lastName);
      List&lt;D3User&gt; findByFirstNameAndLastName(String lastName);
  }
  </code></pre>
  
  <p>I have a Spring/JUnit test that has the following in it which causes the error:</p>
  
  <pre><code>@Autowired
  private D3UserService mD3UserService;
  </code></pre>
  
  <p>The stacktrace is:</p>
  
  <pre><code>Caused by: java.util.NoSuchElementException: null
      at java.util.ArrayList$Itr.next(ArrayList.java:834) ~[na:1.7.0_40]
      at org.springframework.data.jpa.repository.query.ParameterMetadataProvider.next(ParameterMetadataProvider.java:76) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator$PredicateBuilder.build(JpaQueryCreator.java:242) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.toPredicate(JpaQueryCreator.java:144) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.and(JpaQueryCreator.java:96) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryCreator.and(JpaQueryCreator.java:44) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createCriteria(AbstractQueryCreator.java:109) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:88) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.repository.query.parser.AbstractQueryCreator.createQuery(AbstractQueryCreator.java:73) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery$QueryPreparer.&lt;init&gt;(PartTreeJpaQuery.java:98) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.PartTreeJpaQuery.&lt;init&gt;(PartTreeJpaQuery.java:60) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:90) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$CreateIfNotFoundQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:162) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy$AbstractQueryLookupStrategy.resolveQuery(JpaQueryLookupStrategy.java:68) ~[spring-data-jpa-1.3.5.RELEASE.jar:na]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.&lt;init&gt;(RepositoryFactorySupport.java:279) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43) ~[spring-data-commons-1.5.3.RELEASE.jar:na]
      at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ~[spring-beans-3.2.4.RELEASE.jar:3.2.4.RELEASE]
      ... 83 common frames omitted
  </code></pre>
  
  <p>What am I doing wrong?  I have tried many different things from similar posts but nothing has worked.</p>
  
  <p>Please help.</p>