This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Object Relational Mapping and the fly likes Doubt on hibernate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Doubt on hibernate" Watch "Doubt on hibernate" New topic

Doubt on hibernate

syruss kumar
Ranch Hand

Joined: Jul 23, 2009
Posts: 100
Hi all ,

I am newbie for hibernate.I have created a simple Java application Using hibernate .I have kept my hibernate.cfg.xml in my src folder.
but its not recognized .i got this error

Exception in thread "main" org.hibernate.HibernateException: /hibernate.cfg.xml not found.

Please help me to get out from this so i can lot of new things in hibernate.

Thanks in advance.

All search starts with beginner's luck and all search ends with victor's severly tested.
Joachim Rohde
Ranch Hand

Joined: Nov 27, 2006
Posts: 430

Beside the fact that you posted in the wrong forum: your hibernate.cfg.xml must be in the classpath. E.g. put it into the WEB_INF/classes folder. Or search this forum for other possibilities (this question was raised several times here already).
David Newton

Joined: Sep 29, 2008
Posts: 12617

This should be in the ORM forum, as it has nothing to do with Struts.
krishna bala
Ranch Hand

Joined: Jul 20, 2009
Posts: 62
David Newton

Joined: Sep 29, 2008
Posts: 12617

(OT) How would that help?
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper

Joined: Aug 26, 2006
Posts: 4968

Howdy, Greenhorn! Welcome to the ORM forum!

Well, I think what the poster might be getting at is that the hibernate-config.xml file isn't any good in the source folder at runtime. At runtime, the files are pulled from the classes direcotory, or wherever compiled code is placed. Often, Java code gets compiled and put into a build/bin/classes directory, but xml files don't always make the move. Sometimes a manual move out of the source directory and into the bin\classes\compile\build directory allows the runtime environment to pick up the resource.

For the most part, the source code directory isn't on the runtime classpath.

-Cameron McKenzie
I agree. Here's the link:
subject: Doubt on hibernate
It's not a secret anymore!