title: Adding "packagesToScan" sessionFactory property causes noSuchMethodError in Spring
body: <p>I have a Spring (4.1.0.RELEASE) project using Hibernate4.  Everything works, but when I try to add the line:</p>
  
  <pre><code>&lt;property name="packagesToScan" value="com.package.model" /&gt;
  </code></pre>
  
  <p>to my sessionFactory bean, it looks like this:</p>
  
  <pre><code>&lt;bean id="sessionFactory"
      class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"&gt;
      &lt;property name="dataSource" ref="dataSource" /&gt;
      &lt;property name="packagesToScan" value="com.wolf.theivy.auth.model" /&gt;       
      &lt;property name="hibernateProperties"&gt;
          &lt;props&gt;
              &lt;prop key="hibernate.dialect"&gt;org.hibernate.dialect.MySQL5Dialect&lt;/prop&gt;
              &lt;prop key="hibernate.format_sql"&gt;true&lt;/prop&gt;
              &lt;prop key="hibernate.show_sql"&gt;true&lt;/prop&gt;
          &lt;/props&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>However, when I run my webapp, I get the following error:</p>
  
  <pre><code>Error creating bean with name 'sessionFactory' defined in ServletContext 
  resource [/WEB-INF/spring-database.xml]: Invocation of init method failed; 
  nested exception is java.lang.NoSuchMethodError: 
  javax.persistence.Table.indexes()[Ljavax/persistence/Index;
  </code></pre>
  
  <p>which leads me to believe the issue is with the addition of the "packagesToScan" property.  The package is the correct package, so I know that is not a problem.  Another thing to note, I am running the app on a JBoss EAP 6.1+ server, so I'm not sure if that could have anything to do with the error.</p>
  
  <p>EDIT:  </p>
  
  <p>I believe it is something to do with JBoss running JPA 2.0 rather than JPA 2.1, so I am switching to Wildfly 8.1 to see if this will fix the issue.</p>
  
  <p>EDIT 2:</p>
  
  <p>The problem was with JBOSS running JPA2.0, so I switched to Wildfly which completely fixed the problem, since Hibernate 4.3 needs JPA 2.1.  Thanks to all who helped!</p>