-->
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.  [ 8 posts ] 
Author Message
 Post subject: MappingException when using hbm2java
PostPosted: Mon Jan 09, 2006 9:33 pm 
Newbie

Joined: Mon Jan 09, 2006 9:12 pm
Posts: 5
Hi,
I'm a relatively new Hibernate user looking to use hbm2java within ant for a webapp I am developing. I'm using the latest released hibernate-tools.jar, but the tool cannot find my .hbm.xml files, which I've placed in the "project_root/src/org/marketcharts/data/" directory and am pointing to from the hibernate.cfg.xml file in my src/ directory:
<mapping resource="org/marketcharts/data/Ticker.hbm.xml"/>
<mapping resource="org/marketcharts/data/HistoricalQuote.hbm.xml"/>


The error I am receiving is as follows:

bmccann@chameleon:~/Documents/Programs/marketTracker> ant codegen
Buildfile: build.xml

codegen:
[hibernatetool] Executing Hibernate Tool with a Standard Configuration
[hibernatetool] 1. task: hbm2java (Generates a set of .java files)
[hibernatetool] log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
[hibernatetool] log4j:WARN Please initialize the log4j system properly.

BUILD FAILED
/home/bmccann/Documents/Programs/marketTracker/build.xml:227: org.hibernate.MappingException: Resource: org/marketcharts/data/Ticker.hbm.xml not found



Here is the releveant excerpt from my build.xml file which resides in the project root directory:
<!-- Load Hibernate's code generation tool -->
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath"/>


<!-- Generate the java code for all mapping files in our source tree -->
<target name="codegen"
description="Generate Java source from the O/R mapping files">

<hibernatetool destdir="${src.home}">
<classpath refid="project.classpath"/>

<configuration configurationfile="${src.home}/hibernate.cfg.xml" />

<hbm2java />
</hibernatetool>

</target>


Any ideas or help you could give me would be much appreciated.

Thanks,
Ben


Top
 Profile  
 
 Post subject: Figured it out after three days of tairing my hair out
PostPosted: Thu Jan 12, 2006 1:58 pm 
Newbie

Joined: Mon Jan 09, 2006 9:12 pm
Posts: 5
I had to remove the mapping entries from my .cfg.xml file:

<!-- Mapping files -->
<mapping resource="org/marketcharts/data/Ticker.hbm.xml"/>
<mapping resource="org/marketcharts/data/HistoricalQuote.hbm.xml"/>


And I added a fileset to the configuration:
<configuration configurationfile="${src.home}/hibernate.cfg.xml" >
<fileset dir="${src.home}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>


This really seems like a bug to me. I'd rather not have to delete the mappings from my .cfg.xml file everytime I want to update my code.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 3:01 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
huuh ? if the resources are in the classpath of the hibernatetool it works.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: "in the classpath"
PostPosted: Thu Jan 12, 2006 3:58 pm 
Newbie

Joined: Mon Jan 09, 2006 9:12 pm
Posts: 5
I'm not sure what you mean exactly by "in the classpath". I have not set the .hbm.xml files to be in the Java compile path which is surely not what you mean... They are however within the src directory. My first post does state the directories in which each of my files resides.
I was dumbfounded when that turned out to be the solution to my problem since it was not the behavior described in the documentation, but I tried a hundred other things none of which worked. When I put the mapping lines back in the hibernate.cfg.xml file it broke again, so that's definitely the problem as far as I can see. I'd love for this issue to get resolved in future releases, so if there's anything else I can do to help clarify the problems I've had please let me know. This problem occured whether I ran the build through eclipse or not. Also, I am using Suse 10.0 from opensuse.org

-Ben
benmccann.com


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jan 12, 2006 5:06 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are using mapping resource in cfg.xml, those resources need to be in the classpath of the <hibernatetool>

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re; classpath
PostPosted: Thu Jan 12, 2006 6:48 pm 
Newbie

Joined: Mon Jan 09, 2006 9:12 pm
Posts: 5
Thanks. You're right, this was a usage issue. I was unaware that anything other than Java classes, or jars containing Java classes, could be in a classpath. Although it's mostly an issue with my knowledge of ant, it might be helpful if the documentation made this more clear to help other newcomers.


Top
 Profile  
 
 Post subject: ant hbm2java and hibernate 3.1
PostPosted: Sun Feb 12, 2006 9:03 pm 
Newbie

Joined: Sun Feb 12, 2006 8:58 pm
Posts: 1
Seems that changing the configuration line to jdbcconfiguration worked for me. Spent three long hours on this.

Look at this:

<target name="codegen" description="Generate Java source from the O/R mapping files">
<taskdef name="hibernatetool"
classname="org.hibernate.tool.ant.HibernateToolTask"
classpathref="project.classpath"/>
<hibernatetool destdir="${src.dir}">
<classpath refid="project.classpath"/>
<jdbcconfiguration configurationfile="${src.dir}/hibernate.cfg.xml"/>

<!-- <configuration configurationfile="${src.dir}/hibernate.cfg.xml">
<fileset dir="${src.dir}">
<include name="**/*.hbm.xml"/>
</fileset>
</configuration>-->
<hbm2java />
</hibernatetool>
</target>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Feb 13, 2006 1:36 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes...did you read the docs ? (you must have since you could write the ant file)

look at:
"JDBC Configuration for reverse engineering (<jdbcconfiguration>)"

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 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.