-->
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: hibernate.cfg.xml out of classes folder
PostPosted: Thu Feb 02, 2006 8:59 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hibernate version: 2.1.4


Hi,



I´m trying to configure the file hibernate.cfg.xml to other
path. The documentation says "The XML configuration file is placed in the
context classpath (WEB-INF/classes)".

Can I configure this file in other path, out of classes?

I´m trying to do this:
Code:
configuration = (new Configuration()).configure("/META-INF/hibernate.cfg.xml");

this.factory = configuration.buildSessionFactory();


but Doesn´t found the hibernate.cfg.xml.
I cannot put this file together classes folder.

thanks

Obs.: the META-INF folder is separated.

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 10:07 am 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
I think you can put it anywhere on the classpath. Have a think what options that gives you ;o)

What's wrong with the classes folder - e.g. the application classpath?

How about jarring it and sticking it in web-inf/lib - i.e. jar up all your DAO layer in a dao.jar that your web app uses


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 11:02 am 
Senior
Senior

Joined: Wed Sep 24, 2003 3:01 pm
Posts: 158
Location: Bragan�a Paulista - Brasil
Hi,

Well, I need create a .jar but the hibernate.cfg.xml must be out
of this jar file to client configure without unzip the .jar.

thanks!!!!

_________________
Tads


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 02, 2006 12:40 pm 
Regular
Regular

Joined: Wed Jun 29, 2005 11:14 pm
Posts: 119
Location: København
Like I said, I think it can go anywhere on the classpath...

Your options in tomcat (say) therefore would be
1) %CATALINA_HOME%/webapps/YOUR_WEB_APP/WEB-INF/classes
2) %CATALINA_HOME%/webapps/YOUR_WEB_APP/WEB-INF/lib and in a jar
3) %CATALINA_HOME%/server/classes
4) %CATALINA_HOME%/server/lib and in a jar
5) %CATALINA_HOME%/shared/classes
6) %CATALINA_HOME%/shared/lib and in a jar
7) or modify the classpath you start tomcat with

Anything other than 1 or 2 is highly questionable in my opinion, unless of course you want to share an ORM/DAO type layer across multiple web-apps.

If the hibernate.cfg.xml is not in the jar - how is anyone suppose to use it as an ORM?

If you want to offer the model without the DB backing, then create a jar with the model (e.g. the .java files that are mapped to the DB) and create ANOTHER jar with just the .hbm.xml and the .cfg.xml. Then you can offer the code without the hibernate mappings.

If this don't offer enough solutions, then I think you need to say what your exact problem is. I'm not being awkward - just hard to tell why you don't want it in the web-inf/classes....


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.