-->
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.  [ 1 post ] 
Author Message
 Post subject: MVC3 and NHIbernate : An exception occurred during conf.
PostPosted: Wed Aug 31, 2011 9:04 am 
Newbie

Joined: Wed Aug 31, 2011 8:58 am
Posts: 1
As a famous ORM we decided to user nHIbernate with asp.net mvc3. We set up our project in the following way:

NHibernate Repository [contains mappings, service and repositories for nhibernate]
MVC3 [this is a UI]
Test MVC NHibernate [this is a test project with NUnit]

In above, [] text are written ti make clear about the layers.

Everything is working fine, means all Unit Tests are passed for mapping, insert, update, delete operations. Unfotunately, when we are doing the same operation from our mvc3 application then it threw following error:

"An exception occurred during configuration of persistence layer."

Full stack-trace is as follow:

at NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration..ctor(XmlReader hbConfigurationReader, Boolean fromAppSetting) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\ConfigurationSchema\HibernateConfiguration.cs:line 55
at NHibernate.Cfg.ConfigurationSchema.HibernateConfiguration..ctor(XmlReader hbConfigurationReader) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\ConfigurationSchema\HibernateConfiguration.cs:line 36
at NHibernate.Cfg.Configuration.Configure(XmlReader textReader) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1511
at NHibernate.Cfg.Configuration.Configure(String fileName, Boolean ignoreSessionFactoryConfig) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1433
at NHibernate.Cfg.Configuration.Configure(String fileName) in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1418
at NHibernate.Cfg.Configuration.Configure() in d:\CSharp\NH\NH\nhibernate\src\NHibernate\Cfg\Configuration.cs:line 1404
at examplemvcapp.NHibernateRepository..ctor() in D:\example\examplemvcapp-NHExample\examplemvcapp\NHibernateRepository.cs:line 33
at examplemvcapp_NHExample.UI.Models.CreateAppraisalModel..ctor() in D:\example\examplemvcapp-NHExample\examplemvcapp-NHExample.UI\Models\Department.cs:line 70

Please note that all configuration settings for NHIbernate are same in MVC3 app as in Test project.

Following is the guy where we got the exception :

using (var nhr = new NHibernateRepository())
{
this.Departments = nhr.GetAll<Departments>().Select(x => new SelectListItem
{
Text = x.Departmentdescription, Value = x.Id.ToString()
});
}

Above will bring up to following and threw an exception :

public NHibernateRepository()
{
if (sessionFactory == null)
{
config = new Configuration();
config.Configure();
config.AddAssembly(typeof(NHibernateRepository).Assembly);
sessionFactory = config.BuildSessionFactory();
}
Session = sessionFactory.OpenSession();
transaction = Session.BeginTransaction();
Rollback = false;
}

The above is working fine in Test project :

using (var nhr = new NHibernateRepository())
{
var DeptList = nhr.GetAll<Departments>();
}

Any help in this regard is most appreciable.

Regards


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

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.