Using Validator and Envers together

128 views
Skip to first unread message

Jochen Jonckheere

unread,
May 2, 2011, 5:01:32 AM5/2/11
to nhu...@googlegroups.com
Hi,

When I try to use NHibernate.Envers and NHibernate.Validator in the same project I get the following exception.

Mesage: Object reference not set to an instance of an object.
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) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\EventListeners.cs:line 618
   at NHibernate.Event.EventListeners.InitializeListeners(Configuration cfg) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Event\EventListeners.cs:line 592
   at NHibernate.Cfg.Configuration.GetInitializedEventListeners() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1189
   at NHibernate.Cfg.Configuration.BuildSessionFactory() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1246
   at ....Installers.NHibernateInstaller.SessionFactoryFactory(INHibernateConfigurator nHibernateConfigurator, INHibernateEnversConfigurator nHibernateEnversConfigurator) in ...\Installers\NHibernateInstaller.cs:line 81

Here's the part of the code that throws the exception:

// Build the NHibernate Configuration
var nHibernateConfiguration = nHibernateConfigurator.Configure();

// Initialize NHibernate Validator
nHibernateConfiguration.Initialize();

// Initialize NHibernate Envers
nHibernateConfiguration.IntegrateWithEnvers(nHibernateEnversConfigurator.Configure());
// Build the SessionFactory 
_factory = nHibernateConfiguration.BuildSessionFactory();

The exception occurs on the last line. Has somebody succesfully combined Envers and Validator?

Regards,

Jochen

Roger Kratz

unread,
May 2, 2011, 9:16:15 AM5/2/11
to nhu...@googlegroups.com

Don’t know much about NHV and guessing out loud here...

 

conf.IntegrateWithEnvers(...) will add persistent classes to the configuration object. Maybe NHV don’t like modifications of the conf object after it has been initialized? What happens if you run Initialize after IntegrateWithEnvers?

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.

Fabio Maulo

unread,
May 2, 2011, 10:21:43 AM5/2/11
to nhu...@googlegroups.com
Roger,
Probably is a bug in NHV events.
--
Fabio Maulo

Jochen Jonckheere

unread,
May 3, 2011, 9:29:19 AM5/3/11
to nhu...@googlegroups.com
Roger,

If I do IntegrateWithEnvers first than I also have an exception, but with a different Stacktrace:

Mesage: Object reference not set to an instance of an object.
StackTrace:
   at NHibernate.Validator.Cfg.ValidatorInitializer.ApplyValidatorToDDL(PersistentClass persistentClass, ValidatorEngine ve)
   at NHibernate.Validator.Cfg.ValidatorInitializer.Initialize(Configuration cfg, ValidatorEngine ve)
   at NHibernate.Validator.Cfg.ValidatorInitializer.Initialize(Configuration cfg)
   at ....NHibernateInstaller.SessionFactoryFactory(INHibernateConfigurator nHibernateConfigurator, INHibernateEnversConfigurator nHibernateEnversConfigurator) in ...\Installers\NHibernateInstaller.cs:line 83

Jochen

Fabio Maulo

unread,
May 3, 2011, 9:42:55 AM5/3/11
to nhu...@googlegroups.com
The integration with Envers have to be the last integration always.


Jochen

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.



--
Fabio Maulo

Jochen Jonckheere

unread,
May 3, 2011, 9:59:03 AM5/3/11
to nhu...@googlegroups.com
So it's a bug.
Where is the best place to file this bug so that it can be fixed?

Fabio Maulo

unread,
May 3, 2011, 10:24:36 AM5/3/11
to nhu...@googlegroups.com
The NH JIRA 
Go to http://nhforge.org/ and click on "Issue tracker"

On Tue, May 3, 2011 at 10:59 AM, Jochen Jonckheere <jochen.j...@jxk.be> wrote:
So it's a bug.
Where is the best place to file this bug so that it can be fixed?

--
You received this message because you are subscribed to the Google Groups "nhusers" group.
To post to this group, send email to nhu...@googlegroups.com.
To unsubscribe from this group, send email to nhusers+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.



--
Fabio Maulo

Reply all
Reply to author
Forward
0 new messages