This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
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 The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript 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
Author

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

Raminder Singh
Ranch Hand

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

1)

and..
2)

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


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




[/CODE]

Can You please help to resolve??

~raminder.singh
Paul Sturrock
Bartender

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?

~raminder.singh
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Here are your keys

(Configuration.java:addResource:553) - Reading mappings from resource : com/igt/atg/persistance/common/IbeCityMasters.hbm.xml

(Mappings.java:addImport:138) - duplicate import: com.igt.atg.persistance.common.IbeCityMasters->com.igt.atg.persistance.comm
on.IbeCityMasters
(Mappings.java:addImport:138) - duplicate import: com.igt.atg.persistance.common.IbeCityMasters->IbeCityMasters
(HbmBinder.java:bindRootPersistentClassCommonValues:300) - 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
asters.hbm.xml


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 Mappings.java 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.

Mark


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"..it still confuse sometimes..throwing large chunk of SQL..)
- If we not closing seesion in DAO..it 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
Marshal

Joined: Jul 20, 2005
Posts: 10067
    
163

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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error in reading hibernate.cfg.xml after updating hibernate3.jar