I'm having a problem with my configuration loading when I use JUnit. Everything is fine when I run my app normally, through Tomcat. The same problem occured with Tomcat before I upgraded from 2.02 to 2.03. I don't know what the difference could be, both just call: new Configuration().configure()
Here is the debug output:
Code:
23:20:07,977 INFO Configuration:270 - Mapping resource: alea/persist/Organization.hbm.xml
23:20:07,983 DEBUG DTDEntityResolver:20 - trying to locate http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath under net/sf/hibernate/
23:20:07,987 DEBUG DTDEntityResolver:29 - found http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd in classpath
23:20:08,017 INFO Binder:178 - Mapping class: alea.persist.Organization -> organizations
23:20:08,020 DEBUG Binder:394 - Mapped property: id -> org_id, type: long
23:20:08,024 DEBUG Binder:394 - Mapped property: orgType -> org_type_id, type: alea.persist.OrgType
23:20:08,026 DEBUG Binder:394 - Mapped property: parentOrg -> parent_org_id, type: alea.persist.Organization
23:20:08,028 DEBUG Binder:394 - Mapped property: name -> name, type: string
23:20:08,037 DEBUG Binder:394 - Mapped property: status -> status, type: string
23:20:08,039 DEBUG Binder:394 - Mapped property: subTxnId -> subtxn_id, type: long
(dies here)
and stack trace:
Code:
junit.framework.AssertionFailedError: Exception in constructor: testInsert (java.lang.NoClassDefFoundError: org/odmg/DCollection
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:502)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:250)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:299)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:255)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:315)
at net.sf.hibernate.type.TypeFactory.set(TypeFactory.java:184)
at net.sf.hibernate.mapping.Set.getType(Set.java:29)
at net.sf.hibernate.cfg.Binder.propertiesFromXML(Binder.java:875)
at net.sf.hibernate.cfg.Binder.bindRootClass(Binder.java:294)
at net.sf.hibernate.cfg.Binder.bindRoot(Binder.java:1095)
at net.sf.hibernate.cfg.Configuration.add(Configuration.java:230)
at net.sf.hibernate.cfg.Configuration.addInputStream(Configuration.java:252)
at net.sf.hibernate.cfg.Configuration.addResource(Configuration.java:273)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:838)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:792)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:732)
at net.sf.hibernate.cfg.Configuration.configure(Configuration.java:719)
at alea.persist.AbstractHibernateTest.getSession(Unknown Source)
at alea.persist.OrgPhoneTest.<init>(OrgPhoneTest.java:22)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
at junit.framework.TestSuite.createTest(TestSuite.java:135)
at junit.framework.TestSuite.addTestMethod(TestSuite.java:114)
at junit.framework.TestSuite.<init>(TestSuite.java:75)
at alea.persist.OrgPhoneTest.suite(OrgPhoneTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.getTest(RemoteTestRunner.java:335)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:369)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
)
at junit.framework.Assert.fail(Assert.java:47)
at junit.framework.TestSuite$1.runTest(TestSuite.java:263)
at junit.framework.TestCase.runBare(TestCase.java:127)
at junit.framework.TestResult$1.protect(TestResult.java:106)
at junit.framework.TestResult.runProtected(TestResult.java:124)
at junit.framework.TestResult.run(TestResult.java:109)
at junit.framework.TestCase.run(TestCase.java:118)
at junit.framework.TestSuite.runTest(TestSuite.java:208)
at junit.framework.TestSuite.run(TestSuite.java:203)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:392)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:276)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:167)
and the mapping file:
Code:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">
<hibernate-mapping>
<class
name="alea.persist.Organization"
persister="alea.persist.OrganizationPersister"
table="organizations" >
<id name="id" type="long" unsaved-value="null" >
<column name="org_id" not-null="true"/>
<generator class="alea.orm.NullIdentifierGenerator" />
</id>
<many-to-one
name="orgType"
column="org_type_id"
class="alea.persist.OrgType" />
<many-to-one
name="parentOrg"
column="parent_org_id"
class="alea.persist.Organization" />
<property
name="name"
column="name"
type="string" />
<property
name="status"
column="status"
type="string" />
<property
name="subTxnId"
column="subtxn_id"
type="long"
update="false" />
<set
name="orgPhones"
inverse="true"
cascade="all"
lazy="true">
<key column="org_id" />
<one-to-many class="alea.persist.OrgPhone" />
</set>
</class>
</hibernate-mapping>
It is obviously the set that causes the problem, but I don't see any reason for it...
Thanks for any help!
- Ryan