Hi,
Hibernate libraries are deployed separately from my project containing hibernate config, mappings and POJO files. Class loader context is different for each of them, and I'm having difficulties in passing my files. I know how to pass config, mappings and dao files but
I don't know how can I pass composite-id class to hibernate using specified class loader.
When I invoke Configure().addResource(String path, ClassLoader classLoader) mapping and dao files are found, but composite-id dao file not found error occurs. It seems Hibernate doesn't use passed ClassLoader to lookup for it.
dao.class and daoId.class are stored in same place.
Hibernate version:
3.2.5
Code:
Configuration conf = new Configuration().configure(HibernateUtil.class.getClassLoader().getResource("hibernate-serdao.cfg.xml"));
conf.addResource("hbm/Location.hbm.xml", HibernateUtil.class.getClassLoader());
sessionFactory = conf.buildSessionFactory();
Mapping documents: Location.hbm.xml:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated 2007-08-24 13:37:49 by Hibernate Tools 3.2.0.b9 -->
<hibernate-mapping>
<class name="pl.touk.jainslee.serdao.dao.Location" table="location" catalog="ser2_0">
<comment></comment>
<composite-id name="id" class="pl.touk.jainslee.serdao.dao.LocationId">
<key-property name="uid" type="string">
<column name="uid" length="64" />
</key-property>
<key-property name="contact" type="string">
<column name="contact" />
</key-property>
</composite-id>
<property name="aor" type="string">
<column name="aor" not-null="true">
<comment></comment>
</column>
</property>
<property name="received" type="string">
<column name="received">
<comment></comment>
</column>
</property>
<property name="expires" type="timestamp">
<column name="expires" length="0" not-null="true">
<comment></comment>
</column>
</property>
<property name="q" type="float">
<column name="q" precision="12" scale="0" not-null="true">
<comment></comment>
</column>
</property>
<property name="callid" type="string">
<column name="callid">
<comment></comment>
</column>
</property>
<property name="cseq" type="java.lang.Integer">
<column name="cseq">
<comment></comment>
</column>
</property>
<property name="flags" type="int">
<column name="flags" not-null="true">
<comment></comment>
</column>
</property>
<property name="userAgent" type="string">
<column name="user_agent" length="64">
<comment></comment>
</column>
</property>
<property name="instance" type="string">
<column name="instance">
<comment></comment>
</column>
</property>
</class>
</hibernate-mapping>
Full stack trace of any exception that occurs:
2007-08-29 12:59:26.040 INFO [org.hibernate.cfg.Configuration] <StageWorker/16> configuring from url: jar:file:/home/luke/rhino/work/deployments/unit1188385146362/lib.slib-touk-serdao-1.0-SNAPSHOT-oc.jar!/hibernate-serdao.cfg.xml
2007-08-29 12:59:26.047 INFO [org.hibernate.cfg.Configuration] <StageWorker/16> Configured SessionFactory: null
2007-08-29 12:59:26.048 INFO [org.hibernate.cfg.Configuration] <StageWorker/16> Reading mappings from resource: hbm/Location.hbm.xml
2007-08-29 12:59:26.067 INFO [org.hibernate.cfg.HbmBinder] <StageWorker/16> Mapping class: pl.touk.jainslee.serdao.dao.Location -> location
Initial SessionFactory creation failed.org.hibernate.MappingException: component class not found: pl.touk.jainslee.serdao.dao.LocationId
Best regards,
Luke[/i]
|