-->
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.  [ 12 posts ] 
Author Message
 Post subject: HibernateUtil cannot find mapping file during configure()
PostPosted: Tue Nov 01, 2005 1:06 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
I cannot tell from either the manual nor the api exactly how Configure.configure() finds the mapping file(s).

When the code trys - in HibernateUtil - to configure, setting up to buildSessionFactory(), it craters at runtime with an ExceptionInInitializerError reporting in the details that it can't find my mapping file. The mapping file is located in two places: in the same directory (package) as the java source file and in the directory where the deployed class file resides. The application is deployed to tomcat.

I have tried several things to resolve this problem and have so far not found a solution.

Thanks for your help.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 3:03 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
hibernate find hibernate.properties or hibernate.cfg.xml in your classpath

on tomcat it have to be in classes directory or any libraries in WEB-INF/lib


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 3:07 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
It finds hibernate.cfg.xml. It is the mapping file, in my case, ServiceProvider.hbm.xml that it does not find.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 4:18 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
just make sure the path of ServiceProvider.hbm.xml is the classpath matches whatever you have set it to in hibernate.cfg.xml .

post this information if you still have problems.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 4:34 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
it is same for mapping file - it have to be in classpath too

add package + maping file name in hibernate.cfg.xml, for example

<mapping resource="package/ServiceProvider.xml" />

and add package in classes or pack to jar file and save jar in WEB-INF/lib


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 4:40 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
Hi Dennis,

Are you suggesting that I can specify something like this in the hibernate.cfg.xml file:

certify.client.ServiceProvider.hbm.xml (no, surely that will not work)
... uh, maybe:
certify/client/ServiceProvider.hbm.xml

??

Presently, in the hibernate.cfg.xml it is simply:
<mapping resource="ServiceProvider.hbm.xml" />
... as the manual suggests.

I tried putting an import statment in the HibernateUtils file, specifying the package (directory) where it resides (certify.client.*;) That didn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:00 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
You know, if you would have posted your source and configuration in the first posting, you would have a solution by now. But making people guess doesn't work well.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:13 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
oh boy, now you've made Christian mad.

<mapping resource="certify/client/ServiceProvider.hbm.xml" />

/WEB-INF/classes/certify/client/ServiceProvier.hbm.xml
/WEB-INF/classes/certify/client/ServiceProvier.class

... assuming this is a webapp.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:19 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Nah, just watching. If you guys want to chat about "it's the sunspots today!", go ahead :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:40 pm 
Expert
Expert

Joined: Sat Jun 12, 2004 4:49 pm
Posts: 915
is it typeing error ServiceProvider and ServiceProvier


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:43 pm 
Expert
Expert

Joined: Mon Jul 04, 2005 5:19 pm
Posts: 720
oops


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 01, 2005 5:55 pm 
Beginner
Beginner

Joined: Sun Sep 25, 2005 11:57 am
Posts: 29
Whahoo! 86 credits to Dennis. That solved that problem. I have another problem now but I need to see if I can solve this one myself before going back to the well.

Thank you, Dennis ... and for your patience.


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