Page 1 of 1

Error after 7.07. upgrade to Gold R7

Posted: Wed May 14, 2014 8:11 am
by AbleMods
This is the first time I have seen this happen with a Gold upgrade.

Able 7.0.7 site upgraded to Able Gold R7. No errors during upgrade. Login page renders fine. But any attempt to reach the dashboard throws the exception below. Gold site completely unmodified, brand new install.

I can hit other pages in the admin directly without a problem. Edit Users, View a specific Order, Store Settings etc. They all work fine. But soon as I try to reach dashboard (or Order Manager), the exception is thrown.

Any thoughts of what sort of data issue could be causing this?
Server Error in '/' Application.

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[NullReferenceException: Object reference not set to an instance of an object.]
CommerceBuilder.Payments.PaymentRepository.BeforeSave(Object entity) +1094
CommerceBuilder.DomainModel.SaveOrUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) +234
NHibernate.Event.Default.DefaultSaveOrUpdateEventListener.OnSaveOrUpdate(SaveOrUpdateEvent event) +381
NHibernate.Impl.SessionImpl.FireSaveOrUpdate(SaveOrUpdateEvent event) +390
NHibernate.Impl.SessionImpl.SaveOrUpdate(String entityName, Object obj) +389
NHibernate.Engine.Cascade.CascadeToOne(Object parent, Object child, IType type, CascadeStyle style, Object anything, Boolean isCascadeDeleteEnabled) +226
NHibernate.Engine.Cascade.CascadeCollectionElements(Object parent, Object child, CollectionType collectionType, CascadeStyle style, IType elemType, Object anything, Boolean isCascadeDeleteEnabled) +566
NHibernate.Engine.Cascade.CascadeCollection(Object parent, Object child, CascadeStyle style, Object anything, CollectionType type) +274
NHibernate.Engine.Cascade.CascadeOn(IEntityPersister persister, Object parent, Object anything) +600
NHibernate.Event.Default.AbstractFlushingEventListener.CascadeOnFlush(IEventSource session, IEntityPersister persister, Object key, Object anything) +156
NHibernate.Event.Default.AbstractFlushingEventListener.PrepareEntityFlushes(IEventSource session) +372
NHibernate.Event.Default.AbstractFlushingEventListener.FlushEverythingToExecutions(FlushEvent event) +249
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) +160
NHibernate.Impl.SessionImpl.Flush() +499
CommerceBuilder.Common.DatabaseSessionManager.BeginTransaction(IsolationLevel isolationLevel) +93
CommerceBuilder.Services.HttpModule.a(Object A_0, EventArgs A_1) +1170
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +79
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446

Re: Error after 7.07. upgrade to Gold R7

Posted: Wed May 14, 2014 11:58 am
by Katie
Hi Joe,

I've asked the dev team to take a look at the error and see if they can figure out what happened.

Thanks
Katie

Re: Error after 7.07. upgrade to Gold R7

Posted: Wed May 14, 2014 12:18 pm
by AbleMods
Thanks so much Katie, you are always appreciated.

Re: Error after 7.07. upgrade to Gold R7

Posted: Thu May 15, 2014 3:37 am
by Naveed
Thanks for reporting the issue.

There are few helpful hints about the issue, but not clear enough to identify the problem exactly.
[NullReferenceException: Object reference not set to an instance of an object.]
CommerceBuilder.Payments.PaymentRepository.BeforeSave(Object entity) +1094
CommerceBuilder.DomainModel.SaveOrUpdateEventListener.PerformSaveOrUpdate(SaveOrUpdateEvent event) +234
From this part we can see that the issue occurs when it try to save some payments (or order). And null reference exception is thrown in PaymentRepository.BeforeSave() function.
NHibernate.Impl.SessionImpl.Flush() +499
CommerceBuilder.Common.DatabaseSessionManager.BeginTransaction(IsolationLevel isolationLevel) +93
CommerceBuilder.Services.HttpModule.a(Object A_0, EventArgs A_1) +1170
From this part of stack trace, we can see that the code call is initiated from HttpModule when a transaction is started and automatic flush occurs as a result of starting transaction. We only start transaction in the HttpModule.EndRequest() event function. So, some data change about your order or payment occurs before this stage when you load the admin dashboard page.

I have reviewed the related code but yet unable to identify the cause of the issue. Please check the recent orders/payments and see if some part of data is not upgraded/imported properly.

Re: Error after 7.07. upgrade to Gold R7

Posted: Thu May 15, 2014 5:08 am
by AbleMods
Thanks for the response.

I found the cause. I had to load full source into the solution so I could expose the underlying issue.

The problem is the client has a custom payment provider gateway. The custom gateway DLLs were not copied to the new Gold install folder after the data was converted. So the first reference to a payment tries to initialize and cache a provider instance for a class ID that wasn't found in the /bin/ folder.

Not my idea of great error handling though. The system should be able to gracefully handle when a class ID is specified in ac_PaymentGateways but the corresponding class itself is not found in /bin/. As it is right now, it just throws a null exception when it calls the Activator here in PaymentGateway.cs:

Code: Select all

            // see if we found a cached instance
            if (instance == null)
            {
                // provider instance was not in cache so create it
                try
                {
                    instance = Activator.CreateInstance(Type.GetType(this.ClassId)) as IPaymentProvider;
                }
                catch (Exception ex)
                {
                    instance = null;
                    Logger.Error("Could not create provider instance: " + this.ClassId, ex);
                }

                // if we were able to create the instance it needs to be configured
                if (instance != null)
                {
                    instance.Initialize(this.Id, this.ParseConfigData());

                    // and also cache our result
                    if (cache != null)
                    {
                        cache.Add(cacheKey, instance, null, Cache.NoAbsoluteExpiration, new TimeSpan(0, 20, 0), CacheItemPriority.Normal, null);
                    }
                }
            }

Re: Error after 7.07. upgrade to Gold R7

Posted: Fri May 16, 2014 4:30 am
by jmestep
There is something similar with the non-Able FedEx gateway. There is a reference in the table and it keeps throwing errors until the files are added to the bin folder.