0

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!

holtc
  • 1,780
  • 3
  • 16
  • 35
  • 2
    Looks to me like it's successfully scanning the packages, but that one of your Entity beans is marked up incorrectly. The error pertains to @Index items - see if removing those temporarily might help. – Ashley Frieze Nov 22 '14 at 01:05
  • I'm not using anything with @Index. I will keep poking around and try to work with the Entities, I had not thought of that approach, I am fairly new to hibernate. Thanks! – holtc Nov 22 '14 at 01:12
  • I am using Entities with the annotations set on the accessor methods, rather than the fields. Could this be the problem? – holtc Nov 22 '14 at 01:18
  • Most likely you have a JAR conflict, viz. one version of a library used at compile time and another version at runtime. See here: http://stackoverflow.com/questions/20734540/nosuchmethoderror-in-javax-persistence-table-indexesljavax-persistence-index – Alan Hay Nov 22 '14 at 11:01

0 Answers0