-->
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.  [ 2 posts ] 
Author Message
 Post subject: cant find hibernate.cfg.xml
PostPosted: Fri Jan 21, 2011 1:31 pm 
Newbie

Joined: Wed Jan 19, 2011 11:01 am
Posts: 4
hey everyone.

i need to get the connection from a datasource defined in a bean in applicationContext.xml, but i am having problem accessing the file. I tried:
1) Configuration conf = new Configuration();
SessionFactory session = conf.configure().buildSessionFactory();
but it says it doesnt find hibernate.cfg.xml

2) ApplicationContext ctx = new FileSystemXmlApplicationContext("applicationContext.xml");
ComboPooledDataSource ds = (ComboPooledDataSource) ctx.getBean("ds");
but it doesnt find too :(( i changed to WEB-INF/applicationContext and does the same error. Can anybody help me? Need a bean of applicationContext.xml!!!

i have this structure of code inside my proj:
-src
---conf
---java
-----controllers
--------MainContr
-web
---META-INF
---WEB-INF
-----applicationContext.xml
-----dispatcher-servlet.xml
-----hibernate.cfg.xml
-----web.xml

thnx for trying to help me


Top
 Profile  
 
 Post subject: Re: cant find hibernate.cfg.xml
PostPosted: Tue Feb 08, 2011 3:30 pm 
Newbie

Joined: Fri Feb 04, 2011 9:49 pm
Posts: 11
You need to put hibernate.cfg.xml in the root of the class path. This is the most annoying undocumented gotcha (or at least hard to find in the startup exercises) in Hibernate.


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