-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Newbie Question
PostPosted: Fri Jul 15, 2005 4:17 pm 
Newbie

Joined: Fri Jul 15, 2005 4:00 pm
Posts: 2
I'm trying to follow the first Hibernate tutorial and have been hitting some basic problems.

I build a JAR file "htest.jar". When I run, I get:

Initial SessionFactory creation failed.org.hibernate.MappingException: Resource: Event.hbm.xml not found

Obviously, the Hibernate framework can't locate my mapping file. A slightly simplified version of my directory structure is like this:

Code:
c:\workspace\htest
   build.xml
   hibernate.cfg.xml
   log4j.xml
   htest.jar

   src\com\kurt\htest
      Event.hbm.xml
      Event.java
   
   bin\com\kurt\htest
      Event.hbm.xml
      Event.class
   
   lib
      <external jar files such as hibernate, log4j, etc...>


The jar file "htest.jar" is built with the "bin" base directory.
The class path embedded within the manifest file of the jar file contains:
Code:
. bin/com/kurt/htest com/kurt/htest lib/antlr-2.7.5H3.jar <trimmed other jar references>

The second and third path references are redundant but that's OK.

In hibernate.cfg.xml, I have:
Code:
<mapping resource="Event.hbm.xml"/>

Also tried:
Code:
<mapping resource="com\kurt\htest\Event.hbm.xml"/>


I can get this working without using a jar file and using a custom CLASSPATH but I would like to get this working with a full jar file.

This is driving me nuts. It seems like a fairly simple setup issue. I've done plenty of Internet searches and have read many related forum threads and no luck. Any help is greatly appreciated.

Thanks in advance


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 4:32 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
I dont know if this will help, but can you place your mapping xml file at the same place of your VO (Event.java)? It is a good practice.

And make sure that the xml file is copy in the class (execution) folder (class\com\kurt\htest\)... while compiling.... and call the mapping file by using the path : com/package/Event.hbm.xml

Etienne.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 4:33 pm 
Senior
Senior

Joined: Tue Jan 11, 2005 5:03 pm
Posts: 137
Location: Montreal, Quebec
I see you have just done that... it should work


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jul 15, 2005 4:37 pm 
Senior
Senior

Joined: Wed Jul 13, 2005 4:31 pm
Posts: 142
Location: Seattle, WA
Everything looks ok.

Have you tried opening the jar file and seeing if the path is bin/com/.... or com/...

alternatively, could you post the jar task you use?


Top
 Profile  
 
 Post subject: Re: Hibernate Newbie Question
PostPosted: Fri Jul 15, 2005 4:58 pm 
Newbie

Joined: Fri Jul 15, 2005 4:00 pm
Posts: 2
cain wrote:
In hibernate.cfg.xml, I have:
Code:
<mapping resource="Event.hbm.xml"/>

Also tried:
Code:
<mapping resource="com\kurt\htest\Event.hbm.xml"/>



This was the problem. The above two didn't work. This works:

Code:
<mapping resource="com/kurt/htest/Event.hbm.xml"/>


I've literally spent hours tinkering with this; it drove me nuts. Now it's fixed. Thank you guys for helping very much!


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