PDA

View Full Version : Object Reference Error


dressina
07-17-2007, 09:17 PM
We are getting a NullReferenceException sporadically with the following stack trace. We recently upgraded Spring / NHibernate. Any help is appreciated:

2007-07-17 13:13:23,950 [10] ERROR Tradewinds.Samms.Web.BasePage [(null)] - Page Error: System.NullReferenceException: Object reference not set to an instance of an object.
at Spring.Data.NHibernate.Support.OpenSessionInViewMo dule.LazySessionHolder.EnsureInitialized()
at Spring.Data.NHibernate.SessionHolder.get_IsEmpty()
at Spring.Data.NHibernate.SessionFactoryUtils.DoGetSe ssion(ISessionFactory sessionFactory, IInterceptor entityInterceptor, IAdoExceptionTranslator adoExceptionTranslator, Boolean allowCreate)
at Spring.Data.NHibernate.SessionFactoryUtils.GetSess ion(ISessionFactory sessionFactory, IInterceptor entityInterceptor, IAdoExceptionTranslator adoExceptionTranslator, Boolean allowCreate)
at Spring.Data.NHibernate.SessionFactoryUtils.GetSess ion(ISessionFactory sessionFactory, Boolean allowCreate)
at Tradewinds.Samms.Core.DataAccess.NHib.PersistenceM anager.OpenSession()
at Tradewinds.Samms.Procurement.DataAccess.NHib.NHibe rnateProcurementDao.CreateProcurementHeader(Procur ementHeader procurementHeader)
at CompositionAopProxy_779cf31b28d64ec6ac4b64da72768c 2c.CreateProcurementHeader(ProcurementHeader procurementHeader)
at Tradewinds.Samms.Procurement.Business.ProcurementM anager.CreateProcurementHeader(ProcurementHeader procurementHeader)
at Spring.DynamicReflection.Method_CreateProcurementH eader_225cf5bc14e64db793196fd4b6a54b72.Invoke(Obje ct target, Object[] args)
at Spring.Util.DynamicReflection.SafeMethod.Invoke(Ob ject target, Object[] arguments)
at Spring.Aop.Framework.ReflectiveMethodInvocation.In vokeJoinpoint()
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed()
at Spring.Transaction.Interceptor.TransactionIntercep tor.Invoke(IMethodInvocation invocation)
at Spring.Aop.Framework.AbstractMethodInvocation.Proc eed()
at Spring.Aop.Framework.DynamicProxy.AdvisedProxy.Inv oke(Object proxy, Object target, Type targetType, MethodInfo targetMethod, Object[] args, IList interceptors)
at CompositionAopProxy_898ce067884548e68428ffadf3054b 5b.CreateProcurementHeader(ProcurementHeader procurementHeader)
at ProcurementRequestHeader.ProcurementHeader_Add()
at ProcurementRequestHeader.Action_OnCommand(Object sender, CommandEventArgs e)
at System.Web.UI.WebControls.Button.OnCommand(Command EventArgs e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String eventArgument)
at System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Thanks,
Aaron

dressina
07-18-2007, 12:54 AM
My temporary fix for this was to remove transaction attributes that were causing a nested transaction:

Business Manager (Transaction: PROPAGATION_REQUIRED,readOnly) --> DAO (Transaction: PROPAGATION_REQUIRES_NEW).

Once I removed the transaction attribute on the DAO, this error went away. Any ideas? Is it possible to nest transactions this way?

Thanks in advance,
Aaron

Mark Pollack
07-25-2007, 02:26 PM
Hi Aaron,

What versions are you using? Spring 1.1 M2 and NH 1.2 GA? I assume you are using NHibernateTransaction manager? I tested this scenario for TxScopeTransactionManager based on a previous forum issue (tx demarcation on both service and dao layer) and made some fixes for that at the time. It could very likely be that savepoints are not working correctly, which would be the way to do this nesting in ado.net

Cheers,
Mark

dressina
07-25-2007, 04:27 PM
Hi Mark... thanks for the response. We are using Spring.Net 1.1 M1 and NHibernate 1.2 GA. Yes, we are using Spring.Data.NHibernate.HibernateTransactionManager . Nested transactions with the same isolation level / propagation seem to work, just not this case for us. Any help is much appreciated.

Regards,
Aaron