I'm trying to upgrade an Struts/Spring application from Hibernate 3.1 to Hibernate 4.3.
I'm using Untils for my database tests, and under Hibernate 3.1, the tests were working correctly. Under Hibernate 4.3, the tests are failing with the following error:
org.unitils.core.UnitilsException: Could not find a configuring @HibernateSessionFactory annotation or custom config method
at org.unitils.orm.common.OrmModule.getConfiguredPersistenceUnit(OrmModule.java:186)
at org.unitils.orm.common.OrmModule.getPersistenceUnit(OrmModule.java:147)
at org.unitils.orm.common.OrmModule.injectOrmPersistenceUnitIntoTestObject(OrmModule.java:333)
at org.unitils.orm.common.OrmModule$OrmTestListener.beforeTestSetUp(OrmModule.java:379)
at org.unitils.core.Unitils$UnitilsTestListener.beforeTestSetUp(Unitils.java:273)
at org.unitils.UnitilsJUnit4TestClassRunner$TestListenerInvokingMethodRoadie.runBeforesThenTestThenAfters(UnitilsJUnit4TestClassRunner.java:181)
at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:86)
at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:49)
at org.unitils.UnitilsJUnit4TestClassRunner.invokeTestMethod(UnitilsJUnit4TestClassRunner.java:95)
at org.junit.internal.runners.JUnit4ClassRunner.runMethods(JUnit4ClassRunner.java:61)
at org.unitils.UnitilsJUnit4TestClassRunner.access$000(UnitilsJUnit4TestClassRunner.java:42)
at org.unitils.UnitilsJUnit4TestClassRunner$1.run(UnitilsJUnit4TestClassRunner.java:60)
at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:33)
at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:45)
at org.unitils.UnitilsJUnit4TestClassRunner.run(UnitilsJUnit4TestClassRunner.java:67)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
For example, the following test will fail:
@SpringApplicationContext({ configurationFiles })
public class SettlementDAOImplTest extends UnitilsJUnit4 {
@HibernateSessionFactory
private SessionFactory sessionFactory;
@Test
public void type() throws Exception {
assertThat(SettlementDAOImpl.class, notNullValue());
}
}
I've checked my libraries, and I'm loading the correct versions of Unitils and Hibernate, and my sessionFactory is defined as a org.springframework.orm.hibernate4.LocalSessionFactoryBean
At this point, I'm not even sure how to proceed. It appears that Unitils is looking for a hibernate3.localSessionFactoryBean. What should I be looking for to troubleshoot this problem?
In my applicationcontext file, the sessionFactory looks like:
<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource">
<ref local="dataSource" />
</property>
<property name="mappingResources">
<list>
<value>Settlement.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<!-- <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop> -->
<prop key="hibernate.dialect">
com.acteva.commons.util.MySQLDialect
</prop>
<prop key="hibernate.bytecode.provider">javassist</prop>
<prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.cache.use_query_cache">true</prop>
<prop key="hibernate.connection.release_mode">
auto
</prop>
</props>
</property>
<property name="entityInterceptor" ref="entityInterceptorBean" />
</bean>