• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, forgot earlier to share.
Here is HibernateSessionFactory File.
-----------------------------------
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any update on this Mark/Paul?
 
Jaikiran Pai
Marshal
Pie
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Raminder Singh
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic