Innocuous
Innocuous

Reputation: 84

Specifying hibernate mapping file

I have the following file directory

WebContent/search.jsp
WebContent/xml/Car.hbm.xml

I'm creating instantiating the Configuration object as follows:

Configuration cfg = new Configuration()
                    .addResource("xml/Car.hbm.xml");

But it is resulting in MappingException due to Car.hbm.xml file not found.

What's the correct way of specifying the path of the mapping file?

Upvotes: 1

Views: 76

Answers (1)

Zeus
Zeus

Reputation: 6566

Please have a look at this link. If you move the xml folder into WEB-INF directory, the content will be in classpath. Later just do the following, it should take care of finding the xmlfile.

Configuration cfg = new Configuration()
                    .addResource("Car.hbm.xml");

(Or)

Usually the content directly under WebContent are not in classpath unless you specify it in the eclipse project Java build path > sources > Add Folder and select the xml folder. And do the exact same step mentioned above.

Upvotes: 1

Related Questions