-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Xml include using ENTITY fails
PostPosted: Sun Nov 19, 2006 3:33 pm 
Newbie

Joined: Wed May 25, 2005 1:47 pm
Posts: 9
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.2

Mapping documents:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"
[<!ENTITY ekkoProperty SYSTEM "ekko_property.xml" >]
>

<hibernate-mapping
package="com.ekkosoftware.cc.domain">


<class
name="EkkoPropertyValue"
table="property_values"
proxy="EkkoPropertyValue"
entity-name="ControlPropertyValue"
>
&ekkoProperty;
</class>
<class
name="EkkoPropertyValue"
table="test_property_values"
proxy="EkkoPropertyValue"
entity-name="TestPropertyValue"
>
&ekkoProperty;
</class>

</hibernate-mapping>

ekko_property.xml:
<id
name="id"
type="int"
column="PropertyValueID"
>
<generator class="native" />
</id>
<discriminator
column="PropertyType"
type="string"
/>
<many-to-one
name="ekkoProperty"
column="EkkoPropertyID"
class="EkkoProperty"
lazy="false"
fetch="join"
outer-join="true"
/>
<many-to-one
name="ekkoEntity"
column="EntityID"
class="EkkoEntity"
lazy="true"
/>
<subclass name="IntPropertyValue"
discriminator-value="Int"

>
<property name="value"
type="int"
column="IntValue"
></property>
</subclass>
<subclass name="StringPropertyValue"
discriminator-value="String"

>
<property name="value"
type="string"
column="StringValue"
></property>
</subclass>
<subclass name="DatePropertyValue"
discriminator-value="Date"

>
<property name="value"
type="timestamp"
column="DateValue"
></property>
</subclass>


Hi there,

I'm having a problem including an xml file in one of my mapping files using the [!ENTITY xmlEntityName SYSTEM "filename">] syntax in the doctype element.

The app is a java web app running in Tomcat and the creation of the SessionFactory is handled by a static block of the the HibernateUtil class.

When I start tomcat i get the following exception:
org.hibernate.MappingException: Could not read mappings from resource: com/ekkosoftware/cc/domain/EkkoPropertyValue.hbm.xml
which is caused by:
org.dom4j.DocumentException: C:\jakarta-tomcat-5.5.9\bin\ekko_property.xml (The system cannot find the file specified) Nested exception: C:\jakarta-tomcat-5.5.9\bin\ekko_property.xml (The system cannot find the file specified)

Why is Hibernate looking in the tomcat bin directory for the ekko_propery.xml file rather then in the directory which contains the EkkoPropertyValue.hbm.xml file? Obviously i can't hard code the path to the ekko_property.xml file so what do i do?

I'm assuming that this is something to do with classloaders, I thought initially that maybe the parser that hibernate is using to read the mapping files has been loaded by the Tomcat system classloader rather then the web app context classloader, but I'm not really sure how to resolve the issue.

Does anyone have any ideas?

Tom


Top
 Profile  
 
 Post subject: ??
PostPosted: Mon Nov 20, 2006 4:26 pm 
Newbie

Joined: Wed May 25, 2005 1:47 pm
Posts: 9
So no one where has tried to use entity includes in their mapping files then?

Or perhaps my mistake is so obvious no one can be bothered to point it out?

Tom


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 24, 2006 6:08 am 
Newbie

Joined: Fri Oct 28, 2005 9:08 am
Posts: 12
Hello,

I have resolved this issue by including the entity like this :

<!ENTITY ekkoProperty SYSTEM "resource://ekko_property.xml" >

Like this, Hibernate is looking in the classpath.

But it doesn't work in all cases. It works with JBoss but not in a simple Java application. (exception : resource, unknown protocol)
I think it depends on the xml parser.

I search again a solution that works in all cases.

If somenone have an idea, I would be interested.

_________________
Jérémie Balcaen


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 24, 2006 9:16 am 
Newbie

Joined: Fri Oct 28, 2005 9:08 am
Posts: 12
With hibernate 3.2.0, use the protocol classpath://
Hibernate implements its own EntityResolver :

<!ENTITY ekkoProperty SYSTEM "classpath://ekko_property.xml" >

(see paragraph 5.1.1.1 of the hibernate guide reference (version 3.2final).

_________________
Jérémie Balcaen


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.