Thanks for your help, it was just an oversight on my part. I'm caching
the session factory now so that should hopefully resolve it

On May 15, 8:06 am, Paul Batum <paul.ba...@gmail.com> wrote:
> When you use Fluently.Configure(), it builds a session factory. When it
> comes to figuring out what to do with that session factory, its best to
> follow typical NH best practices because once you have a session factory,
> theres nothing "fluent" about it.
>
> An old but quite popular article on NH best practices is 
> here:http://www.codeproject.com/KB/architecture/NHibernateBestPractices.aspx
>
> There is probably a more recent one somewhere. Maybe take a look at how the
> sharp architecture project does its session management.
>
> Virtually ANYTHING is better than creating a session factory per request.
> That simply won't scale.
>
> On Fri, May 15, 2009 at 4:26 PM, JamesSpibey <james.spi...@gmail.com> wrote:
>
> > Hi Paul,
>
> > Actually the mappings are built every time a unit of work is
> > instantiated which is typically once per request. This is because the
> > unit of work creates a new session and that uses the configution from
> > FNH.
>
> > Sounds like I've made a mistake here - so should the mappings be built
> > in Application_Start? In which case, where are they typically 'stored'
> > between requests or does FNH do all that for you?
>
> > Thanks
>
> > James
>
> > On May 15, 3:06 am, Paul Batum <paul.ba...@gmail.com> wrote:
> > > Hi James,
>
> > > Can you clarify, you say you get 1 or 2 errors per thousand requests -
> > what
> > > are the exceptions that you are getting? Because the stack trace you
> > > provided was for the process of building the mapping, which should only
> > be
> > > done once as your application spins up. You're not rebuilding the session
> > > factory from scratch per request, right?
>
> > > Inspecting your stack trace, it looks like this error should always
> > occur,
> > > or never occur. The process of building the mappings should be
> > > deterministic.
>
> > > Paul Batum
>
> > > On Thu, May 14, 2009 at 7:54 PM, JamesSpibey <james.spi...@gmail.com>
> > wrote:
>
> > > > Hi,
>
> > > > We deployed a new version of our app today which now users FNH to
> > > > configure our NHibernate instance. We were previously using L2S.
>
> > > > We are seeing random errors coming from our server farm which are
> > > > being raised by FNH, mostly during the buildings of the mappings. The
> > > > errors are not consistent (it may be 1 or 2 per thousand requests) but
> > > > it's enough to cause an issue. These FNH errors then lead to
> > > > NHibernate errors which I believe is because the mappings are in an
> > > > inconsistent state.
>
> > > > Here's an example Call Stack
>
> > > > ---> System.ArgumentException: The node to be inserted is from a
> > > > different document context.
> > > >   at System.Xml.XmlNode.AppendChild(XmlNode newChild)
> > > >   at
> > > > FluentNHibernate.MappingModel.Output.XmlPropertyWriter.ProcessProperty
> > > > (PropertyMapping propertyMapping) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlPropertyWriter.cs:line 50
> > > >   at FluentNHibernate.MappingModel.PropertyMapping.AcceptVisitor
> > > > (IMappingModelVisitor visitor) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel
> > > > \PropertyMapping.cs:line 15
> > > >   at FluentNHibernate.MappingModel.Output.XmlPropertyWriter.Write
> > > > (PropertyMapping property) in D:\Data\Dev\TS\Catalogue\External\fluent-
> > > > nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlPropertyWriter.cs:line 20
> > > >   at FluentNHibernate.MappingModel.Output.XmlClassWriterBase.Visit
> > > > (PropertyMapping propertyMapping) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlClassWriterBase.cs:line 18
> > > >   at FluentNHibernate.MappingModel.MappedMembers.AcceptVisitor
> > > > (IMappingModelVisitor visitor) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel
> > > > \MappedMembers.cs:line 68
> > > >   at
> > > > FluentNHibernate.MappingModel.ClassBased.ClassMappingBase.AcceptVisitor
> > > > (IMappingModelVisitor visitor) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel\ClassBased
> > > > \ClassMappingBase.cs:line 32
> > > >   at
> > > > FluentNHibernate.MappingModel.ClassBased.ClassMapping.AcceptVisitor
> > > > (IMappingModelVisitor visitor) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel\ClassBased
> > > > \ClassMapping.cs:line 87
> > > >   at FluentNHibernate.MappingModel.Output.XmlClassWriter.Write
> > > > (ClassMapping mapping) in D:\Data\Dev\TS\Catalogue\External\fluent-
> > > > nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlClassWriter.cs:line 30
> > > >   at
> > > > FluentNHibernate.MappingModel.Output.XmlHibernateMappingWriter.Visit
> > > > (ClassMapping classMapping) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlHibernateMappingWriter.cs:line 58
> > > >   at FluentNHibernate.MappingModel.HibernateMapping.AcceptVisitor
> > > > (IMappingModelVisitor visitor) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\MappingModel
> > > > \HibernateMapping.cs:line 52
> > > >   at
> > > > FluentNHibernate.MappingModel.Output.XmlHibernateMappingWriter.Write
> > > > (HibernateMapping mapping) in D:\Data\Dev\TS\Catalogue\External\fluent-
> > > > nhibernate\src\FluentNHibernate\MappingModel\Output
> > > > \XmlHibernateMappingWriter.cs:line 24
> > > >   at FluentNHibernate.Xml.MappingXmlSerializer.BuildXml
> > > > (HibernateMapping rootMapping) in D:\Data\Dev\TS\Catalogue\External
> > > > \fluent-nhibernate\src\FluentNHibernate\Xml
> > > > \MappingXmlSerializer.cs:line 52
> > > >   at FluentNHibernate.Xml.MappingXmlSerializer.Serialize
> > > > (HibernateMapping mapping) in D:\Data\Dev\TS\Catalogue\External\fluent-
> > > > nhibernate\src\FluentNHibernate\Xml\MappingXmlSerializer.cs:line 15
> > > >   at FluentNHibernate.PersistenceModel.Configure(Configuration cfg)
> > > > in D:\Data\Dev\TS\Catalogue\External\fluent-nhibernate\src
> > > > \FluentNHibernate\PersistenceModel.cs:line 208
> > > >   at FluentNHibernate.Cfg.FluentMappingsContainer.Apply(Configuration
> > > > cfg) in D:\Data\Dev\TS\Catalogue\External\fluent-nhibernate\src
> > > > \FluentNHibernate\Cfg\FluentMappingsContainer.cs:line 113
> > > >   at FluentNHibernate.Cfg.MappingConfiguration.Apply(Configuration
> > > > cfg) in D:\Data\Dev\TS\Catalogue\External\fluent-nhibernate\src
> > > > \FluentNHibernate\Cfg\MappingConfiguration.cs:line 52
> > > >   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in
> > > > D:\Data\Dev\TS\Catalogue\External\fluent-nhibernate\src
> > > > \FluentNHibernate\Cfg\FluentConfiguration.cs:line 110
> > > >   --- End of inner exception stack trace ---
> > > >   at FluentNHibernate.Cfg.FluentConfiguration.BuildConfiguration() in
> > > > D:\Data\Dev\TS\Catalogue\External\fluent-nhibernate\src
> > > > \FluentNHibernate\Cfg\FluentConfiguration.cs:line 119
> > > >   at NHS.Data.NHibernate.NHUnitOfWorkFactory.get_Configuration() in D:
> > > > \Data\Dev\TS\Catalogue\OrderServices\NHibernateRepository\UnitOfWork
> > > > \NHUnitOfWorkFactory.vb:line 22
> > > >   at NHS.Data.NHibernate.NHUnitOfWorkFactory.get_SessionFactory() in
> > > > D:\Data\Dev\TS\Catalogue\OrderServices\NHibernateRepository\UnitOfWork
> > > > \NHUnitOfWorkFactory.vb:line 38
> > > >   at NHS.Data.NHibernate.NHUnitOfWorkFactory.CreateSession() in D:
> > > > \Data\Dev\TS\Catalogue\OrderServices\NHibernateRepository\UnitOfWork
> > > > \NHUnitOfWorkFactory.vb:line 76
> > > >   at NHS.Data.NHibernate.NHUnitOfWorkFactory.Create() in D:\Data\Dev
> > > > \TS\Catalogue\OrderServices\NHibernateRepository\UnitOfWork
> > > > \NHUnitOfWorkFactory.vb:line 61
> > > >   at NHS.Common.Data.UnitOfWork.Start() in D:\Data\Dev\TS\Catalogue
> > > > \Common\Common\UnitOfWork\UnitOfWork.vb:line 46
> > > >   at
>
> > NHS.Catalogue.Web.Controllers.StructureMapControllerFactory.GetControllerInstance
> > > > (Type controllerType) in D:\Data\Dev\TS\Catalogue\Catalogue
> > > > \CatalogueWeb\Helpers\StructureMapControllerFactory.vb:line 20
> > > >   at System.Web.Mvc.DefaultControllerFactory.CreateController
> > > > (RequestContext requestContext, String controllerName)
> > > >   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase
> > > > httpContext)
> > > >   at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext
> > > > httpContext)
> > > >   at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest
> > > > (HttpContext httpContext)
> > > >   at
>
> > System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute
> > > > ()
> > > >   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step,
> > > > Boolean& completedSynchronously)
>
> > > > Thanks for any suggestions
>
> > > > Regards
>
> > > > James
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Fluent NHibernate" group.
To post to this group, send email to fluent-nhibernate@googlegroups.com
To unsubscribe from this group, send email to 
fluent-nhibernate+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/fluent-nhibernate?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to