gauravoli
gauravoli

Reputation: 74

Error: /hibernate.cfg.xml not found

I am using Eclipse "Indigo". I made a Java Project with the following Structure:
Hibernate (Project Name)
src
Referenced Libraries
JRE System Libraries
employee.hbm.xml
hibernate.cfg.xml


Now when I am running my code its showing error "/hibernate.cfg.xml not found"
Is there a way to set a path for hibernate configuration file??

Upvotes: 0

Views: 7288

Answers (3)

Mark Bramnik
Mark Bramnik

Reputation: 42541

Its obviously a wrong setup. You can get a detailed explanations by searching in google how to setup eclipse to work with hibernate. There are even video tutorials about this. Like this one :)

Good luck

Upvotes: 1

Matin Kh
Matin Kh

Reputation: 5178

hibernate.cfg.xml has to be in your classpath. So create a source folder (like your src) and put it there. Like this:
1. Create a source folder named "properties"
2. Put your hibernate.cfg.xml there
3. Give properties/hibernate.cfg.xml address in your application.
4. If you are using this hibernate configuration file in your XML files, you have to use this address: classpath:properties/hibernate.cfg.xml

Upvotes: 0

markosca
markosca

Reputation: 136

You must put hibernate.cfg.xml into src directory (in the same folder that your packages or class).

src/
com.mypackage/myJava.java
com.otherPackage
hibernate.cfg.xml

In addition, in eclipse you can define a resources directory, add it to the path and put there the hibernate.cfg.xml

I hope help you. Marcos

Upvotes: 5

Related Questions