These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Windows service gives mapping exception, console app doesn't
PostPosted: Thu Sep 20, 2007 12:45 pm 
Newbie

Joined: Mon Jun 04, 2007 12:26 pm
Posts: 13
Location: Houston, Texas
Problem: I have a console app with a class that uses nhibernate 1.2 GA which works fine. I use the class in a windows service and get this error on the first sql query: NHibernate.DuplicateMappingException.

Is there anything special I should be aware of when using NHibernate in a windows service? Thanks.

Full stack trace of any exception that occurs:
From event.log --
Service cannot be started. NHibernate.MappingException: Could not compile the mapping document: Pappas.Domain.Domain.SettlementHist.hbm.xml ---> NHibernate.DuplicateMappingException: Duplicate class/entity mapping SettlementOfflineHist
at NHibernate.Cfg.Mappings.AddClass(PersistentClass persistentClass)
at NHibernate.Cfg.HbmBinder.PropertiesFromXML(XmlNode node, PersistentClass model, Mappings mappings)
at NHibernate.Cfg.HbmBinder.BindRootClass(XmlNode node, RootClass model, Mappings mappings)
at NHibernate.Cfg.HbmBinder.BindRoot(XmlDocument doc, Mappings mappings)
at NHibernate.Cfg.Configuration.AddValidatedDocument(XmlDocument doc, String name)
--- End of inner exception stack trace ---
at Pappas.Domain.NHDao`1.GetObject(String query)
at Pappas.BatchProcessor.GetConstants()
at Pappas.BatchProcessor..ctor()
at Pappas.BatchProccessorService.OnStart(String[] args)
at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)


Top
 Profile  
 
 Post subject: Configuration
PostPosted: Fri Sep 21, 2007 2:06 pm 
Regular
Regular

Joined: Wed Jan 25, 2006 1:11 am
Posts: 118
Location: Copenhagen, Denmark
Try to post you configuration part either from cfg.xml some of the cases i can think of that this exception comes:

- You have the <class name="SettlementOfflineHist" ..> twice in your mappingfiles

- You have added the Assembly containing the mappingfiles to the configuration twice

- Your config file points to the mapping assembly and you add the assembly manually to the configuration as well.


Top
 Profile  
 
 Post subject: Re: Configuration
PostPosted: Mon Sep 24, 2007 1:11 pm 
Newbie

Joined: Mon Jun 04, 2007 12:26 pm
Posts: 13
Location: Houston, Texas
You were correct - I was using different config files for my console app and my windows service, causing me to load the mappings twice. I can't believe I missed that.

Thanks again.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.