AddStaticAttributePropertyValues object reference exception

Member since: 2014

Hi,

We are using EPiServer.Commerce v9.14.1 and we have encoutnered an issue with our products search page.

Suddenly, the page was throwing below error:

System.NullReferenceException: Object reference not set to an instance of an object.
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddStaticAttributePropertyValues(CatalogEntryRow entryRow, EntryContentBase content)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadStaticContentProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content)
   at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content, MetaObjectAccessor metaObjectAccessor)
   at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IList`1 entryNodeRelations, String language)
   at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
   at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
   at EPiServer.Core.ContentProvider.<>c__DisplayClass114_0.<LoadContentFromCacheOrRepository>b__0()
   at EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject)
   at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
   at EPiServer.Core.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
   at EPiServer.Core.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
   at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
   at EPiServer.Commerce.Routing.RequestCacheUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
   at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)
   at EPiServer.Web.Mvc.Html.UrlExtensions.ContentUrl(UrlHelper urlHelper, ContentReference contentLink)
   at ASP._Page_Views_Shared_Products_Details_cshtml.Execute() in ~\Views\Shared\Products\Details.cshtml:line 88
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
   at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
   at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
   at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
   at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
   at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
   at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Recycling app pool fixed the issue.

Any idea what might have caused this error?

Thanks!

#150686 Jun 27, 2016 16:30
  • Member since: 2005

    Hi

    Looking at the code it seems like the problem seems to be in this section of code:

    content.ApplicationId = entryRow.ApplicationId.ToString();
    content.CatalogId = entryRow.CatalogId;
    content.Code = entryRow.Code;
    content.MetaClassId = entryRow.MetaClassId;
    content.Name = entryRow.Name;
    content.StartPublish = GetLocalTime(entryRow.EntryStartDate(content.Language.Name));
    content.StopPublish = GetLocalTime(entryRow.EntryEndDate(content.Language.Name));
    content.Categories.ContentLink = content.ContentLink;
    content.Associations.ContentLink = content.ContentLink;
    content.ParentEntries.ContentLink = content.ContentLink;

    Which would indicate that either something on the entryRow or the content is unexpectedly null. If you turn on log4net logging on debug level for the class CatalogPropertyLoader, and have error logging on for the whole site, you should be able to find out which item it fails on. There shold be a message like "Calling LoadStaticContentProperties with parameter values: ", and the values used, just before the exception. Maybe that could give some hints as to what's the cause of this error.

    Regards

    Per Gunsarfs

    #150698 Jun 28, 2016 9:26
  • Member since: 2011

    Hi,

    When the issue happens, is it consistent until you restart the app pool?

    #150699 Jun 28, 2016 9:37
  • Member since: 2014

    @Per - We will enable debug next time if happened (wish not!) to get more hints.

    @Quan - Yes, it was consistent in all our thumbnail pages until we restarted the app pool.

    #150736 Jun 28, 2016 20:27
  • Member since: 2014

    So, I enabled DEBUG mode this time and I've got almost same error:

    2016-08-11 08:27:23,387 [120] ERROR EPiServer.Global: 1.2.5 Unhandled exception in ASP.NET
    System.NullReferenceException: Object reference not set to an instance of an object.
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddStaticAttributePropertyValues(CatalogEntryRow entryRow, EntryContentBase content)
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadStaticContentProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow,
    EntryContentBase content)
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content,
    MetaObjectAccessor metaObjectAccessor)
    at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IList`1 entryNodeRelations, String
    language)
    at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
    at EPiServer.Core.ContentProvider.<>c__DisplayClass114_0.<LoadContentFromCacheOrRepository>b__0()
    at EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject)
    at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
    at EPiServer.Core.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
    at EPiServer.Core.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
    at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
    at EPiServer.Commerce.Routing.RequestCacheUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
    at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)
    at EPiServer.Web.Mvc.Html.UrlExtensions.ContentUrl(UrlHelper urlHelper, ContentReference contentLink)
    at ASP._Page_Views_Shared_Products_Details_cshtml.Execute() in ~\Views\Shared\Products\Details.cshtml:line 88
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
    at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
    System.NullReferenceException: Object reference not set to an instance of an object.
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddStaticAttributePropertyValues(CatalogEntryRow entryRow, EntryContentBase content)
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadStaticContentProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow,
    EntryContentBase content)
    at EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content,
    MetaObjectAccessor metaObjectAccessor)
    at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, IDictionary`2 versionsForUnpublishedContent, IList`1 entryNodeRelations, String
    language)
    at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.ConstructContent(IList`1 contentLinks, Func`3 createContentFunc)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.LoadSpecificContentInstances(IList`1 contentLinks, String language)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.BatchLoad(IList`1 contentLinks, Func`2 dbLoader)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector)
    at EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector)
    at EPiServer.Core.ContentProvider.<>c__DisplayClass114_0.<LoadContentFromCacheOrRepository>b__0()
    at EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject)
    at EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector)
    at EPiServer.Core.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions)
    at EPiServer.Core.DefaultContentLoader.TryGet[T](ContentReference contentLink, LoaderOptions loaderOptions, T& content)
    at EPiServer.Web.Routing.DefaultUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
    at EPiServer.Commerce.Routing.RequestCacheUrlResolver.GetVirtualPathInternal(ContentReference contentLink, String language, VirtualPathArguments arguments)
    at EPiServer.Web.Routing.UrlResolver.GetUrl(ContentReference contentLink, String language)
    at EPiServer.Web.Mvc.Html.UrlExtensions.ContentUrl(UrlHelper urlHelper, ContentReference contentLink)
    at ASP._Page_Views_Shared_Products_Details_cshtml.Execute() in ~\Views\Shared\Products\Details.cshtml:line 88
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
    at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
    at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
    at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext,
    ActionResult actionResult)
    at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
    at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass21.<BeginInvokeAction>b__1e(IAsyncResult asyncResult)
    at System.Web.Mvc.Controller.<BeginExecuteCore>b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
    at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

    Apparently this line of code is causing the issue: 

    if (Model.ParentProductContentLink != null)

             parentProductURL = Url.ContentUrl(Model.ParentProductContentLink.Value);   //Where ParentProductContentLink  property is of type Lazy<ContentReference>

    Your feedback is highly appreciated!

    #151992 Aug 11, 2016 15:54
  • Looking at the exception thrown, looks the same as in this thread. http://world.episerver.com/forum/developer-forum/Problems-and-bugs/Thread-Container/2016/9/commerce-catalog-randomly-goes-empty-until-website-restart/

    #155387 Sep 15, 2016 14:33
  • Member since: 2011

    Great catch @Rene. It definitely looks like that was the problem.

    The solution for future visitors: Make sure your Commerce Manager, or any sites which don't have the strongly typed catalog content types to have enableModelSyncCommit = "false" in web.config:

     <episerver>     

    <applicationSettings enableModelSyncCommit="false" uiUrl="~/UI/" enableScheduler="false" />   

    </episerver>


    #155392 Sep 15, 2016 14:48
  • You're welcome :) But actually you where the one who gave me the answer, look at the bottom of this thread ;) http://world.episerver.com/Modules/Forum/Pages/Thread.aspx?id=133442

    #155394 Sep 15, 2016 14:56
  • Member since: 2014

    Thanks a ton Rene and Quan!

    I will give it a try.

    #155398 Sep 15, 2016 15:14