Hi all,
I'm having problems running my DAO unit tests now that I've written a comparator class to sort a set in my entity:
Code:
/**
* Returns all available transatlantic flights.
* @return
* @hibernate.set where="flightType='T'" inverse="true" cascade="all-delete-orphan"
* sort="org.iom.sima.util.FeederComparator"
* @hibernate.collection-one-to-many class="org.iom.sima.model.FlightInformation"
* @hibernate.collection-key column="bookingId"
*/
public Set getTransAtlanticFlights() {
return transAtlanticFlights;
}
I get the following error:
[junit] org.hibernate.MappingException: Could not instantiate comparator class: org.io
m.sima.util.FeederComparator
[junit] at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:1229)
[junit] at org.hibernate.cfg.HbmBinder$2.create(HbmBinder.java:2510)
[junit] at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1697)
[junit] at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBind
er.java:317)
[junit] at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235)
[junit] java.lang.ExceptionInInitializerError
[junit] at java.lang.Class.forName0(Native Method)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUn
itTestRunner.java:204)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUn
itTestRunner.java:177)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUn
itTestRunner.java:651)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnit
TestRunner.java:558)
[junit] at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
[junit] at org.hibernate.cfg.Configuration.add(Configuration.java:360)
[junit] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:397)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropert
iesSet(LocalSessionFactoryBean.java:567)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa
ctory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:937)
[junit] Caused by: org.springframework.beans.factory.BeanCreationException: Error crea
ting bean with name 'sessionFactory' defined in file [C:\work\sandbox\cbuweb\build\dao\gen
\META-INF\applicationContext-hibernate.xml]: Initialization of bean failed; nested excepti
on is org.hibernate.MappingException: Could not instantiate comparator class: org.iom.sima
.util.FeederComparator
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa
ctory.createBean(AbstractAutowireCapableBeanFactory.java:341)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(A
bstractBeanFactory.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(A
bstractBeanFactory.java:146)
[junit] at org.springframework.beans.factory.support.DefaultListableBeanFactory.pr
eInstantiateSingletons(DefaultListableBeanFactory.java:271)
[junit] at org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:319)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<ini
t>(ClassPathXmlApplicationContext.java:80)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<ini
t>(ClassPathXmlApplicationContext.java:65)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa
ctory.createBean(AbstractAutowireCapableBeanFactory.java:334)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(A
bstractBeanFactory.java:222)
[junit] at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(A
bstractBeanFactory.java:146)
[junit] at org.springframework.beans.factory.support.DefaultListableBeanFactory.pr
eInstantiateSingletons(DefaultListableBeanFactory.java:271)
[junit] at org.springframework.context.support.AbstractApplicationContext.refresh(
AbstractApplicationContext.java:319)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<ini
t>(ClassPathXmlApplicationContext.java:80)
[junit] at org.springframework.context.support.ClassPathXmlApplicationContext.<ini
t>(ClassPathXmlApplicationContext.java:65)
[junit] at org.iom.sima.dao.BaseDAOTestCase.<clinit>(BaseDAOTestCase.java:34)
[junit] at org.iom.sima.dao.BaseDAOTestCase.<clinit>(BaseDAOTestCase.java:34)
[junit] ... 6 more
[junit] at java.lang.Class.forName0(Native Method)
[junit] Caused by: org.hibernate.MappingException: Could not instantiate comparator cl
ass: org.iom.sima.util.FeederComparator
[junit] at org.hibernate.cfg.HbmBinder.bindCollection(HbmBinder.java:1229)
[junit] at org.hibernate.cfg.HbmBinder$2.create(HbmBinder.java:2510)
[junit] at org.hibernate.cfg.HbmBinder.createClassProperties(HbmBinder.java:1697)
[junit] at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBind
er.java:317)
[junit] at java.lang.Class.forName(Class.java:141)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUn
itTestRunner.java:204)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.<init>(JUn
itTestRunner.java:177)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.launch(JUn
itTestRunner.java:651)
[junit] at org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner.main(JUnit
TestRunner.java:558)
[junit] at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:235)
[junit] at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:151)
[junit] at org.hibernate.cfg.Configuration.add(Configuration.java:360)
[junit] at org.hibernate.cfg.Configuration.addInputStream(Configuration.java:397)
[junit] at org.springframework.orm.hibernate3.LocalSessionFactoryBean.afterPropert
iesSet(LocalSessionFactoryBean.java:567)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa
ctory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:937)
[junit] at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFa
ctory.createBean(AbstractAutowireCapableBeanFactory.java:334)
[junit] ... 13 more
[junit] Exception in thread "main"
[junit] Test org.iom.sima.dao.ProFlightDAOTest FAILED
Note that when I run the actual application, the comparator works fine. It only fails for the unit tests.
I already tried putting the comparator class explicitly in the class path for the JUnit target to no avail.
Anyone know what's causing this problem?
Br,
-Yves-