Search code examples
c#nhibernatefluent-nhibernatenhibernate-mappingnhibernate-envers

Fluent Configuration Exception


if (_cacheSessionFactory == null)
{
    Configuration config = null;
    _cacheSessionFactory = ReadOrBuildConfiguration().ExposeConfiguration(
        cfg =>
            {
                SetSessionContext(cfg);
                cfg.SetListener(ListenerType.Flush, new PostFlushFixEventListener());
                ConfigureValidator(cfg);
                if (EnversConfiguration != null)
                {
                    cfg.SetEnversProperty(ConfigurationKey.StoreDataAtDelete, true);
                    cfg.IntegrateWithEnvers(EnversConfiguration);
                }
            }).ExposeConfiguration(cfg => { config = cfg; }).BuildSessionFactory();

    using (_cacheSessionFactory.OpenSession())
    {
        BuildSchema(config);
    }
}

UPDATED stack trace

FluentNHibernate.Cfg.FluentConfigurationException was unhandled by user code
  HResult=-2146233088
  Message=An invalid or incomplete configuration was used while creating a SessionFactory. Check PotentialReasons collection, and InnerException for more detail.

  * Database was not configured through Database method.
  * No mappings were configured through the Mappings method.

  Source=FluentNHibernate
  StackTrace:
       at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
       at NhibDataAccess.NhibernateSetup.CreateSessionFactory() in d:\Jorell\PROJECTS\NhibDataAccess\NhibernateSetup.cs:line 105
       at NhibDataAccess.NhibernateSetup.get_SessionFactory() in d:\Jorell\PROJECTS\NhibDataAccess\NhibernateSetup.cs:line 67
       at NhibDataAccess.UnitOfWork.LongRunningUnitOfWork.get_SessionFactory() in d:\Jorell\PROJECTS\NhibDataAccess\UnitOfWork\LongRunningUnitOfWork.cs:line 63
       at Web.Global.Application_EndRequest(Object sender, EventArgs e) in d:\Jorell\PROJECTS\Web\Global.asax.cs:line 54
       at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
       at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
  InnerException: System.NullReferenceException
       HResult=-2147467261
       Message=Object reference not set to an instance of an object.
       Source=NHibernate.Validator
       StackTrace:
            at NHibernate.Validator.Engine.SystemTypeExtensions.ShouldNeedValidation(Type clazz)
            at NHibernate.Validator.Engine.ValidatorEngine.GetClassValidator(Type entityType)
            at NHibernate.Validator.Engine.ValidatorEngine.AddValidator(Type entityType, IValidatableSubElementsInspector inspector)
            at NHibernate.Validator.Event.ValidatePreInsertEventListener.Initialize(Configuration cfg)
            at NHibernate.Event.EventListeners.InitializeListeners(Configuration cfg, Object[] list)
            at NHibernate.Event.EventListeners.InitializeListeners(Configuration cfg)
            at NHibernate.Cfg.Configuration.GetInitializedEventListeners()
            at NHibernate.Cfg.Configuration.BuildSessionFactory()
            at FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory()
       InnerException: 

when i try to add any Audit<> in EnversConfiguration this exception is thrown. i have a similar application and this doesn't happen. any clue or information as to why this problem occurs?


Solution

  • the problem in my code was already addressed before i even knew it. please visit the site for more information

    https://nhibernate.jira.com/browse/NHV-117