I have a Spring (4.1.0.RELEASE) project using Hibernate4. Everything works, but when I try to add the line:
<property name="packagesToScan" value="com.package.model" />
to my sessionFactory bean, it looks like this:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan" value="com.wolf.theivy.auth.model" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop>
<prop key="hibernate.format_sql">true</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
</bean>
However, when I run my webapp, I get the following error:
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;
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.
EDIT:
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.
EDIT 2:
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!