-->
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.  [ 7 posts ] 
Author Message
 Post subject: Tomcat:Could not read mapping doc. Absloute/relativ path
PostPosted: Thu Mar 23, 2006 9:57 am 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
hi,

I am trying to use hibernate 3 from tomcat but I am running into problem reading my mapping files. I deployed my application as a war into tomcat. I want to use entitymanager so I use the following code:

Code:
private void setEntityManager(final Properties connect) throws Exception
{   
Properties properties = connect;
Ejb3Configuration cfg = new Ejb3Configuration();
cfg.addProperties(properties);

//this is where the exception is thrown
cfg.addFile(new File("User.hbm.xml"));
}

When attempt to add hbm files into my configration, the server is not able to find them. I added a print statement to see where tomcat is looking for the files:

Code:
File f = new File("User.hbm.xml");
System.out.println("1- path = " + f.getAbsolutePath());

// I get
1- path = C:\Program Files\Tomcat 5.5\bin\User.hbm.xml


which is a path relative to the tomcat install. My app is deployed at C:\Program Files\Tomcat 5.5\webapps\myapp

I tried to change the format I am passing to the Ejb3Configuration but it always try to look in the bin directory of tomcat. Short of using absloute path, I can not think of anything else. Any suggestions?

Khalid


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 28, 2006 11:31 pm 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
I would appreciate any help on this. It seems that my hbm files have to go under my Tomcat 5.5\bin\ but I am sure that there is a way to place them inside my war. Any suggestions?

Khalid


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 4:48 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Use some other form of adding a persistent class.
For example: cfg.addClass(User.class);


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 7:00 am 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
That would work if I annotate the entites. However I still need to use the hbm files for my hql queries so I need to figure out how to include them using the relative path in my war.

Khalid


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 7:43 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Why don't you simply add mappings through cfg file?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 8:38 am 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
since I am using the entitymanager, I thought that I need to use persistence.xml file to list my hbm files. Last I checked listing hbm files within a persistence.xml was not supported. So I am back at trying to use Ejb3Configuration and trying to add files to it.

thanks,

Khalid


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 29, 2006 8:52 am 
Expert
Expert

Joined: Sat Oct 25, 2003 8:49 am
Posts: 490
Location: Vrhnika, Slovenia
Add this to your persistence.xml
Code:
<property name="hibernate.ejb.cfgfile" value="/hibernate.cfg.xml"/>


And then simply add mappings into cfg.


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