I am trying to get a simple hibernate mapping to work with JUnit. There is a 'Preferences.java' and 'Preferences.hbm.xml' file and 'hibernate.cfg.xml'. However, I get a mapping exception saying that 'Preferences.hbm.xml' cannot be found.
1. I've checked the classpath. It's OK. 2. The '<id/> tag in 'Preferences.hbm.xml' looks like this:
<id
name="id"
type="java.lang.Integer"
column="ID" >
<generator class="sequence"/>
</id>
... and it works when using it in Tomcat. However, using it in JUnit causes problems. Here's the exception output:
1) testCreate(net.rnet.ut.TestPreferences)junit.framework.AssertionFailedError: <<< MappingException occured: Error reading resource: net/rnet/db/Preferences.hbm.xml
at net.rnet.ut.TestPreferences.testCreate(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
I'd appreciate any ideas from someone who's resolved this before. There seem to be too many obscure classpath issues for hibernate.
-- tim
|