-->
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 not found?
PostPosted: Wed Feb 08, 2006 5:52 am 
Newbie

Joined: Fri Feb 03, 2006 3:24 am
Posts: 3
Hey guys,

I'm having trouble reading the hibernate.cfg.xml. Actually, I'm having trouble locating it.

I'm using JBuilder2006 and Hibernate Version 3.0.


Here are the lines of code containing the pathfinding of my cfg.xml:

Code:
configFileURL = HibernatePlugIn.class.getResource(_configFilePath);

            tempString = ""+configFileURL;
            System.out.println(" tempString: "+tempString);
            tempString = tempString.substring(6);
            System.out.println(" tempString: "+tempString);
            context = _servlet.getServletContext();

            if (_log.isDebugEnabled()) {
                _log.debug("Initializing Hibernate from "
                        + _configFilePath + "...");
            }

            configuration = (new Configuration()).configure(tempString);
            _factory = configuration.buildSessionFactory();


Using getResource, I'm loading the path of the config file, which is correctly found:

Quote:
configFilePath: /hibernate.cfg.xml
tempString: file:/D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
tempString: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml


Alright, the file is located in that folder. I've also put it into the folders
    MCM/WebModule1/WEB-INF
    MCM/WebModule/
    MCM/
but he always tells me the same error, which is:

Quote:
08:31:37,317 INFO Configuration:1286 - configuring from resource: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
08:31:37,317 INFO Configuration:1263 - Configuration resource: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml
08:31:37,347 ERROR HibernatePlugIn:132 - Exception while initializing Hibernate.
08:31:37,387 ERROR HibernatePlugIn:133 - Rethrowing exception...
org.hibernate.HibernateException: D:/JBuilder2006/Projects/MCM/WebModule1/WEB-INF/classes/hibernate.cfg.xml not found


So what's up with that? In which folder DO I have to put it now? Or is the problem somewhere else and I didn't find it?

Thanks for your help, it is really needed...


Top
 Profile  
 
 Post subject: Re: hibernate.cfg.xml not found?
PostPosted: Wed Feb 08, 2006 6:08 am 
Beginner
Beginner

Joined: Mon Jan 30, 2006 2:28 am
Posts: 47
Location: INDIA
Hi!

Try to place your hibernate.cfg.xml in src foler. If we use two tables, we need to create two .hbm.xml files. for eg., i am using 2 tables 1.userlogin 2.studentinfo. so i need to create userlogin.hbm.xml and studentinfo.hbm.xm. files. These two files should be configured in hibernate.cfg.xml.


Try 2 ways for placing hibernate.cfg.xml file
1. Try to place your hibernate.cfg.xml file in src folder or
2. Try to plcace your hibernate.cfg.xml file in Hibernate session factory
located file directory or
3. Pls check the sample hibernate application
http://www.laliluna.de/first-hibernate- ... orial.html

_________________
A.Edward Durai
"The things which are impossible with men are possible with God."


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 2:07 pm 
Regular
Regular

Joined: Fri Sep 09, 2005 11:35 am
Posts: 101
you need not specify the absolute file path for hibernate.cfg.xml.

(new Configuration()).configure(tempString);

The parameter tempString should be the classpath relative path to the hibernate.cfg.xml. So here you could directly pass _configFilePath to this method and it should work.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 09, 2006 2:56 pm 
Newbie

Joined: Fri Feb 03, 2006 3:24 am
Posts: 3
Hey, great!

Now he is able to find the file.
Got another error, but maybe I can solve that problem on my own now.

Thanks for the help!


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.