File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Object Relational Mapping and the fly likes Getting a org.hibernate.MappingNotFoundException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Getting a org.hibernate.MappingNotFoundException" Watch "Getting a org.hibernate.MappingNotFoundException" New topic

Getting a org.hibernate.MappingNotFoundException

P Rajendra Prasad

Joined: Jul 25, 2012
Posts: 2

so i started learning hibernate, and i was writing my first program. I had everything in place, like i added all hibernate libraries, and placed hibernate.cfg.xml in src folder and i created a class "User" which i had to persist.
I had added that class to '<mapping>' tag (with fully qualified domain name).
But when i run the program, it shows up this....

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation logger implementation
SLF4J: See for further details.
Exception in thread "main" org.hibernate.MappingNotFoundException: resource: org.test.www.model.User not found
at org.hibernate.cfg.Configuration.addResource(
at org.hibernate.cfg.Configuration.parseMappingElement(
at org.hibernate.cfg.Configuration.parseSessionFactory(
at org.hibernate.cfg.Configuration.doConfigure(
at org.hibernate.cfg.Configuration.doConfigure(
at org.hibernate.cfg.Configuration.configure(
at org.hibernate.cfg.Configuration.configure(
at org.test.www.impl.Driver.main(

and by the way, 'Driver' is my implementation class.

my hibernate.cfg.xml file is as below.....

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@//localhost:1521/XE</property>
<property name="hibernate.connection.username">HR</property>
<property name="hibernate.connection.password">tiger</property>
<property name="connection.pool_size">1</property>
<property name="hibernate.dialect">org.hibernate.dialect.Oracle10gDialect</property>
<property name="cache.provider_class">org.hibernate.cache.NoCacheProvider</property>
<property name="show_sql">true</property>
<property name="">create</property>
<mapping resource="org.test.www.model.User"></mapping>
please help me out, i really appreciate it.
Paul Clapham

Joined: Oct 14, 2005
Posts: 18135

canyon quest wrote:Exception in thread "main" org.hibernate.MappingNotFoundException: resource: org.test.www.model.User not found.

So presumably "User" corresponds to a User class in your system? Then you need a Hibernate configuration file for that class in your project. In the same folder as your main Hibernate configuration file would be the best choice, I think.

Edit: I see you have this reference:

<mapping resource="org.test.www.model.User"></mapping>

In my configuration the "resource" attribute contains the name of the resource, not the name of the class it describes. So in my configuration it would look like this:

P Rajendra Prasad

Joined: Jul 25, 2012
Posts: 2

Thanks for the reply paul, but there is tiny problem. I am learning the hibernate through video tutorials, and if you see the following video "", you will notice that there was no configuration of such .hbm resource file anywhere. I did everything that was shown in the video, but yet i get this error. please can you look into that.
tyte kyat
Ranch Hand

Joined: May 17, 2011
Posts: 40
I am also a newbie here.

But, I think I can point out your problem here.

you said you did mapping as follow

If I am right resource is used to map another XML format file. Here in your case, you have to use as follow

I agree. Here's the link:
subject: Getting a org.hibernate.MappingNotFoundException
Similar Threads
Automatic Schema Generation
Could not parse configuration: /hibernate.cfg.xml
org.hibernate.HibernateException: Could not parse configuration: /hibernate.cfg.xml
Could not parse configuration: /hibernate.cfg.xml
Nested exception: Content is not allowed in prolog