special0ne
special0ne

Reputation: 6263

Can not load the hbm file in hiberante

I am trying to do the Hibernate tutotial from JBoss web site. Basically it is a very simple application that adds an Event to the DB.

There is an org.hibernate.tutorial.domain.Event and an Event.hbm.xml file.

The problem is that: regardless of what i am doing i am getting an org.hibernate.MappingNotFoundException resource: Event.hbm.xml not fohund, when i initialize the Configuration object. I initilize it as follows:

File hibernateCfgFile = new File("C:/Program Files/Development/IDE/workspace/Hibernate3.6/hibernate.cfg.xml");
        try {
            // Create the SessionFactory from hibernate.cfg.xml
            return new Configuration().configure(hibernateCfgFile).buildSessionFactory();
        }

I have tried to specify in the hibernate.cfg.xml file the full path to the hbm file but with no success.

another wierd point is that I have to specify the hibernate.cfg.xml location. with out that it would not find the file even if it is in the src folder.

Any ideas??

Upvotes: 0

Views: 841

Answers (2)

Piyush Mattoo
Piyush Mattoo

Reputation: 16095

Place your mapping file in the root directory next to hibernate.cfg.xml file.

Upvotes: 0

Don
Don

Reputation: 401

First of all, you should put any hibernate (or other resources) on your java classpath. Your second problem is the space in "Program Files". I find it is best to keep anything that may need to programmatically read from the file system as far away from the dreaded "Program Files" directory as possible.

Upvotes: 2

Related Questions