Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Could not read mappings from resource ?

Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Please help me with the following problem

Following Error message when run using store as the initial argument.


log4j:WARN No appenders could be found for logger (org.hibernate.cfg.Environment).
log4j:WARN Please initialize the log4j system properly.
Initial SessionFactory creation Could not read mappings from resource: com/ibm/hibernate_article/Employee.hbm.xml
Exception in thread "main" java.lang.ExceptionInInitializerError
at com.ib.hibernate_article.EmpManager.createAndStoreEmp(
at com.ib.hibernate_article.EmpManager.main(
Caused by: org.hibernate.MappingException: Could not read mappings from resource: com/ibm/hibernate_article/Employee.hbm.xml
at org.hibernate.cfg.Configuration.addClass(
at com.ib.util.HibernateUtil.<clinit>(
... 2 more
Caused by: org.hibernate.PropertyNotFoundException: field not found: empName
at org.hibernate.util.ReflectHelper.getter(
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(
at org.hibernate.cfg.HbmBinder.bindSimpleId(
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(
at org.hibernate.cfg.HbmBinder.bindRootClass(
at org.hibernate.cfg.HbmBinder.bindRoot(
at org.hibernate.cfg.Configuration.add(
at org.hibernate.cfg.Configuration.addInputStream(
at org.hibernate.cfg.Configuration.addClass(
... 3 more

Best Regards

[ October 19, 2006: Message edited by: Ayub ali khan ]

[Editied to use code tags - Paul Sturrock]
[ October 25, 2006: Message edited by: Paul Sturrock ]
Ranch Hand
Posts: 547
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in case this is still a problem:
you have a space in the property name:

<id name=" empName " column="EMPNAME">

should be

<id name="empName " column="EMPNAME">

Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe you need to check the place you put the mapping file...

The package location must be the same than the java file...
Posts: 17346
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Plus, you can't have the same attribute be your id and a property at the same time.

I would keep EMPNAME as a property and not make it an ID, it is a really bad candidate for an ID, because you could have two Joe Smith's in your database and then you are in trouble. Always make your ids, as the following

1. a Long
2. named id
3. not a business field in your database, let the database use its native incrementor, whatever that is. This is called a surrogate key, and has no business meaning to it, like EMPNAME does.

She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic