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 Error in reading hibernate.cfg.xml after updating hibernate3.jar Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Error in reading hibernate.cfg.xml after updating hibernate3.jar" Watch "Error in reading hibernate.cfg.xml after updating hibernate3.jar" New topic

Error in reading hibernate.cfg.xml after updating hibernate3.jar

Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
I was getting some errors on initializing hibernate environment:



I got new hibernate jar v:3.2.2 and replaced it with old.
My both errors warnings Got SOLVED..

its not reading hibernate.cfg.xml file now..
saying some duplicate entry.


Can You please help to resolve??

Paul Sturrock

Joined: Apr 14, 2004
Posts: 10336

This is probably failing because you have com/igt/atg/persistance/common/IbeCityMasters.hbm.xml defined twice in hibernate.cfg.xml. Check there is only one mapping in there.

JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
I have checked...there are no any duplicate entries.
If it would, it should give error message even with old jar.

Even, I have checked that DTD syntex define in both jar's sample hibernate.cfg.xml is same.

any more help?

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17271

Here are your keys

( - Reading mappings from resource : com/igt/atg/persistance/common/IbeCityMasters.hbm.xml

( - duplicate import: com.igt.atg.persistance.common.IbeCityMasters->com.igt.atg.persistance.comm
( - duplicate import: com.igt.atg.persistance.common.IbeCityMasters->IbeCityMasters
( - Mapping class: com.igt.atg.persistance.common.IbeCityMasters -> IB
E_CITY_MASTERS07/01/31 13:57:05 %%%% Error Creating SessionFactory %%%%
org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/igt/atg/persistance/common/IbeCityM

So there is an issue with the IbeCityMasters.hbm.xml. Either it is somehow declared twice like Paul had mentioned, or there is something wrong with the mapping of the class. Please also post the IbeCityMasters.hbm.xml,

Very interesting, after trying to read Hibernate's code and manually step through, I find that the addImport method of the file is called when there is an "import" tag in your mapping files, either the hibernate.cfg.xml or the IbeCityMasters.hbm.xml file.

I actually don't know the "import" tag. So then my question would be why do you use that tag? And I could be completely wrong in my assumption here, and missed some other place in the Hibernate code where the addImport method is being called, but I doubt that right now. Or is auto-import set in your mapping to true?

I love questions like this that allow me to go into the Hibernate code and search for the answer, it really helps me learn about how Hibernate is build. It is really cool and very very very well written, very OO, simple, and general whenever possible for extensibility.


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
thanks a lot Mark and Paul.

There is no any 'import' in .cfg.xml OR .hbm.xml.
But I got a that hibernate is reading the configuration file twice at time of initilizing. (Check code)

- I'm putting contents of IBECity to app. cache at start using struts+hibenate.
- We are using struts -> EJB -> DAO -> Hibernate -> Oracle 10g. (using lazy="false" still confuse sometimes..throwing large chunk of SQL..)
- If we not closing seesion in gives error while saving...!!

Here is log output:

- Help me where I'm wrong?
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Sorry, forgot earlier to share.
Here is HibernateSessionFactory File.
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Any update on this Mark/Paul?
Jaikiran Pai

Joined: Jul 20, 2005
Posts: 10433

Going by the exception stacktrace its appears to be related to wrong version of a jar being present in the classpath. Make sure you are using the correct version of asm.jar and asm-attrs.jar. Also make sure that you dont have multiple such jars in your classpath.

[My Blog] [JavaRanch Journal]
Raminder Singh
Ranch Hand

Joined: Mar 01, 2002
Posts: 72
Thanks jai kiran.
I put two mentioned jars by you and hibernate3.jar in my classpath and in oracle10g home/j2ee/home/applib...and it works.

Thanks a lot.
I agree. Here's the link:
subject: Error in reading hibernate.cfg.xml after updating hibernate3.jar
jQuery in Action, 3rd edition