Reputation: 23
eventhough I have correctly structured my project, when I am getting error in mapping Employee.hbm.xml as below:
here is my Exception code
Exception in thread "main" java.lang.ExceptionInInitializerError
at net.viralpatel.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java:16)
at net.viralpatel.hibernate.HibernateUtil.<clinit>(HibernateUtil.java:8)
at net.viralpatel.hibernate.Main.list(Main.java:26)
at net.viralpatel.hibernate.Main.main(Main.java:75)
Caused by: org.hibernate.MappingNotFoundException: resource: net/viralpatel/hibernate/Employee.hbm.xml not found
at org.hibernate.cfg.Configuration.addResource(Configuration.java:738)
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2188)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2160)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2140)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2093)
at org.hibernate.cfg.Configuration.configure(Configuration.java:2008)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1987)
at net.viralpatel.hibernate.HibernateUtil.buildSessionFactory(HibernateUtil.java)
Any suggestion for this..
Upvotes: 0
Views: 1616
Reputation: 5612
So what
org.hibernate.MappingNotFoundException: resource:
net/viralpatel/hibernate/Employee.hbm.xml not found
means is that a file called "Employee.hbm.xml" is not being picked up on the classpath.
Check that:
net/viralpatel/hibernate
net
directory is on the classpath (for example, in WEB-INF/classes
if
you're running a webapp)Upvotes: 0
Reputation: 4853
Check the mapping class configuration in Hibernate.cfg.xml
.
You have mapped the Employee.hbm.xml
in cfg.xml
but mentioned path not found, Ensure that the Employee.hbm.xml
is available in correct path..
Eg.
In hibernate.cfg.xml
<mapping class="pojo.Holidays" resource="pojo/Holidays.hbm.xml"/>
Here the Holidays.hbm.xml
is under pojo
directory, if the xml
is not available under pojo
directory, it will show the above Exception
Upvotes: 1