File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

what is the default location of hibernate.cfg.xml

 
sudheer kiran
Ranch Hand
Posts: 237
Firefox Browser MyEclipse IDE Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am getting error,hibernate.cfg.xml not found
whille using return new Configuration().configure().buildSessionFactory();

what is the first location that hibernate will look for hibernate.cfg.xml.

thanks
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It needs to be on the classpath in the default package (i.e. in the folder all your classes are).
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The question gets asked alot in here. Do a quick forum search and you'll find lots of people in the same shoes as you.

If you have folder such as \source that all your classes and packages are in, you typically put the hibernate-config.xml file in there. But remember, at runtime, it needs to be moved to your runtime classpath. Build tools usually compile and move Java code to a \build or \bin or \classes directory. Sometimes the config file doesn't get moved as well. So, make sure that config file is on the RUNTIME classpath, not just your build time classpath.

Here's a little tutorial I put together on setting up a Hibernate environment:

Getting Started with Hibernate - Configuring a Standard XP Environment

Good luck! If this doesn't help, tell us more about your environment.

-Cameron McKenzie
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic