Try our conversational search powered by Generative AI!

Null pointer issue when resolving url

Vote:
 

Hi,

I have upgraded to version 8.16.1 of Commerce and everything has been working fine but today I took a dump of the test database (still running an older version of EPiServer/Commerce) and the migration runns fine but after that I get the following error when trying to resolve a commerce reference,

----

[NullReferenceException: Object reference not set to an instance of an object.]
EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.AddStaticAttributePropertyValues(CatalogEntryRow entryRow, EntryContentBase content) +631
EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadStaticContentProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content) +198
EPiServer.Commerce.Catalog.Provider.Construction.CatalogPropertyLoader.LoadProperties(CatalogEntryRow entryRow, CatalogItemSeoRow seoRow, VariationRow variationRow, EntryContentBase content) +168
EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, String language, IList`1 contentLinks, IList`1 entryNodeRelations) +885
EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language) +512
EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.GetContentFromBuilder(String language, IEnumerable`1 linkByType) +537
EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.GetItems(IList`1 contentLinks, String language) +1113
EPiServer.Commerce.Catalog.Provider.CatalogContentDraftStore.GetItems(IList`1 contentLinks, String language) +580
EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContents(IList`1 contentReferences, ILanguageSelector selector) +217
EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.LoadContent(ContentReference contentLink, ILanguageSelector languageSelector) +263
EPiServer.Core.<>c__DisplayClass23.b__22() +138
EPiServer.Core.OptimisticCache`1.Read(String cacheKey, ReadAndCacheObject`1 readAndCacheObject) +1175
EPiServer.Core.ContentProvider.LoadContentFromCacheOrRepository(ContentReference contentreference, ILanguageSelector selector) +746
EPiServer.Core.ProviderPipelineImplementation.GetItem(ContentProvider provider, ContentReference contentLink, LoaderOptions loaderOptions) +346
EPiServer.Core.DefaultContentLoader.TryGet(ContentReference contentLink, LoaderOptions loaderOptions, T& content) +574
EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.ResolveContent(ContentReference contentLink) +151
EPiServer.Commerce.Catalog.Provider.CatalogContentProvider.ResolveContent(Guid contentGuid) +218
EPiServer.Core.ContentProvider.EPiServer.Web.IContentResolver.ResolveContent(Guid contentGuid) +37
EPiServer.Web.PermanentContentLinkMapper.FindInternal(Guid guid) +282
EPiServer.Web.PermanentLinkMapper.Find(Guid guid, StorePreference preferredStore) +352
EPiServer.Web.PermanentLinkMapper.Find(UrlBuilder url) +777
EPiServer.Web.Routing.DefaultUrlResolver.GetUrl(UrlBuilder urlBuilderWithInternalUrl, VirtualPathArguments arguments) +75
EPiServer.Web.Mvc.Html.UrlExtensions.ContentUrl(UrlHelper urlHelper, Url url) +133
ASP._Page_Views_StartPage_Partials_Slider_cshtml.Execute() in c:\Projects\Slider.cshtml:7

----

The same error appers when trying to browse the catalog in EPiServer CMS, I can just see nodes but no entries. I have also downloaded the production database but with that database the site runns fine after the migration. Hopefully it will not be an issue when going live but it feels very scary to have this error in one of the databases. Any idé of what have gone wrong and if we can do something to fix the issue if it happens when we move to production?

/Viktor

#133442
Sep 04, 2015 13:19
Vote:
 

Hi!

Looking at the code of AddStaticAttributePropertyValues I'm guessing that the problem occurs in this chunk:

content.ApplicationId = entryRow.ApplicationId.ToString();
content.CatalogId = entryRow.CatalogId;
content.Code = entryRow.Code;
content.MetaClassId = entryRow.MetaClassId;
content.Name = entryRow.Name;
content.StartPublish = entryRow.StartDate.ToLocalTime();
content.StopPublish = entryRow.EndDate.ToLocalTime();
content.Categories.ContentLink = content.ContentLink;
content.Associations.ContentLink = content.ContentLink;
content.ParentEntries.ContentLink = content.ContentLink;

That would guess that either start date, end date or application id is missing on an entry. Can you look into the test data where you have this problem and see if you can find a suspicious entry?

Regards

Per Gunsarfs

#133676
Sep 08, 2015 15:41
Vote:
 

Hi,

Thanks, I ran this queries in the database,

-------------

SELECT ApplicationId
FROM CatalogEntry
GROUP BY ApplicationId

SELECT StartDate
FROM CatalogEntry
GROUP BY StartDate

SELECT EndDate
FROM CatalogEntry
GROUP BY EndDate

------------

And everything looked good, on ApplicationId used for all items and all items had valid start and end dates. Is there another table I should check in?

/Viktor

#133678
Sep 08, 2015 16:20
Vote:
 

Hmm, then I'm not really sure what it could be.

I would suggest turning on debug logging, as there is a decent amount of logging in the CatalogPropertyLoader class. If debug logging is turned on for that class (I suggest you scope the logging for the class or it's namespace, as full debug logging is very verbose) you should see a message just before the exception that the "LoadStaticContentProperties" method was called, and arguments what it was called with. That should give some clues as to what item that has the problematic data.

/Per

#133714
Sep 09, 2015 10:56
Vote:
 

Hi,

Ok got this message in the log,

------------

2015-09-09 11:23:34,566 DEBUG ?.? - Calling 'GetClosestSetting' with parameter values: 1322
2015-09-09 11:23:34,573 DEBUG ?.? - Calling 'ResolveContent' with parameter values: 4b37b5d7-54b4-4011-d98d-2627165539b7
2015-09-09 11:23:34,580 DEBUG ?.? - Calling 'ResolveContent' with parameter values: 596__CatalogContent
2015-09-09 11:23:34,587 DEBUG ?.? - Calling 'LoadContent' with parameter values: 596__CatalogContent, EPiServer.Core.LanguageSelectorForProvider
2015-09-09 11:23:34,595 DEBUG ?.? - Calling 'LoadContents' with parameter values: System.Collections.Generic.List`1[EPiServer.Core.ContentReference], EPiServer.Core.LanguageSelectorForProvider
2015-09-09 11:23:34,608 DEBUG ?.? - Calling 'GetItems' with parameter values: System.Collections.Generic.List`1[EPiServer.Core.ContentReference], de
2015-09-09 11:23:34,616 DEBUG ?.? - Calling 'GetContentFromBuilder' with parameter values: System.Linq.GroupedEnumerable`3[EPiServer.Core.ContentReference,Mediachase.Commerce.Catalog.CatalogContentType,EPiServer.Core.ContentReference]
2015-09-09 11:23:34,624 DEBUG ?.? - Calling 'Create' with parameter values: System.Collections.Generic.List`1[EPiServer.Core.ContentReference], de
2015-09-09 11:23:34,637 DEBUG ?.? - Calling 'Create' with parameter values: Variation, 5, de, 1
2015-09-09 11:23:34,644 DEBUG ?.? - Calling 'GetContentTypeModel' with parameter values: 5
2015-09-09 11:23:34,650 DEBUG ?.? - Calling 'Create' with parameter values: Company.Brand.Core.Models.MetaData.SiteProductContent, de, 1
2015-09-09 11:23:34,657 DEBUG ?.? - Calling 'CreateContent' with parameter values: EPiServer.DataAbstraction.ContentType, EPiServer.Construction.BuildingContext
2015-09-09 11:23:34,663 DEBUG ?.? - Calling 'VerifyLanguageSetup' with parameter values: Castle.Proxies.SiteProductContentProxy, de, 1
2015-09-09 11:23:34,673 DEBUG ?.? - Calling 'LoadProperties' with parameter values: Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+CatalogEntryRow, Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+CatalogItemSeoRow, Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+VariationRow
2015-09-09 11:23:34,679 DEBUG ?.? - Calling 'LoadStaticContentProperties' with parameter values: Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+CatalogEntryRow, Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+CatalogItemSeoRow, Mediachase.Commerce.Catalog.Dto.CatalogEntryDto+VariationRow, Castle.Proxies.SiteProductContentProxy
2015-09-09 11:23:34,733 ERROR ?.? - 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)
at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.ConstructEntries(CatalogEntryDto entryDto, String language, IList`1 contentLinks, IList`1 entryNodeRelations)
at EPiServer.Commerce.Catalog.Provider.Construction.EntryBuilder.Create(IList`1 contentLinks, String language)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.GetContentFromBuilder[T](String language, IEnumerable`1 linkByType)
at EPiServer.Commerce.Catalog.Provider.CatalogContentLoader.GetItems[T](IList`1 contentLinks, String language)

------------

I have looked any closer at the log output but will do that now, just wanted to postit here first.

/Viktor

#133716
Sep 09, 2015 11:27
Vote:
 

Hi,

Ok, I found entry with id 596, I was also able to find it in the Commerce Manager. I deleted the item from Commerce Manager and could not find it anymore but the site still crashed at the same point and entry with id 596 was still in the database so ran the following SQL query,

-----

DELETE FROM CatalogItemSeo WHERE CatalogEntryId = 596
DELETE FROM CatalogEntry WHERE CatalogEntryId = 596

-----

to remove the item and now the startpage loades but I still get the same error when loading the product list page for the next error product. I guess if I remove that product from the database I will get the error for the next product etc. etc.

/Viktor

#133718
Sep 09, 2015 12:57
Vote:
 

Hi,

When you delete an item from Commerce Manager, it should delete all information in related tables properly, no SQL needed.

I suspect you have a faulty catalog, but it's really hard for us to diagnose remotely like this to know what is wrong. What I can suggest is to try to export the catalog, delete it then reimport. It hopefully correct the faulty values.

If the problem still exists, you might need to contact our Developer Support services for proper investigation.

Regards,

/Q

#133720
Sep 09, 2015 13:58
Vote:
 

Hi,

Yes, just stupid me who did not switch the connection string for the commerce manager to my local DB when trying to delete the item...

I exported the catalog but when I import it again it creates two levels of nodes but the third level is created right under the catalog, but I still get the same error message on the site.

The site was created on a pre-release version of EPiServer 7.5 so it my be some junk in the database? I will contact developer support.

/Viktor

#133724
Sep 09, 2015 16:43
Vote:
 

"

I exported the catalog but when I import it again it creates two levels of nodes but the third level is created right under the catalog, but I still get the same error message on the site.

"

Sound like issues with NodeRelation and/or NodeEntryRelation.

A possible way to try:

- Install a 7.5 site, attach to the database

- export the catalog

- import again in your current site.

Of course contacting our developer support services is one way to go.

Regards,

/Q

#133726
Sep 09, 2015 17:05
Vote:
 

Hi,

I connected the Commerce database to a Quicksilver installation and did the export there and then imported again but still with the same structure error. I have sent the database to developer support now and hope they can find something wrong. Thanks for your help! 

/Viktor

#133731
Sep 09, 2015 17:45
Vote:
 

Hi,

The support case related to your issue has been resolved. The problem was the ParentEntries property definition for your content type was missing from [tblPropertyDefinition].

This is supposed to fix your issue:

  insert into [dbo].[tblPropertyDefinition]
  ([fkContentTypeID]
      ,[fkPropertyDefinitionTypeID]
      ,[FieldOrder]
      ,[Name]
      ,[Property]
      ,[Required]
      ,[Advanced]
      ,[Searchable]
      ,[EditCaption]
      ,[HelpText]
      ,[ObjectProgID]
      ,[DefaultValueType]
      ,[LongStringSettings]
      ,[SettingsID]
      ,[LanguageSpecific]
      ,[DisplayEditUI]
      ,[ExistsOnModel])
   
  (SELECT TOP 1 
      21
      ,[fkPropertyDefinitionTypeID]
      ,[FieldOrder]
      ,[Name]
      ,[Property]
      ,[Required]
      ,[Advanced]
      ,[Searchable]
      ,[EditCaption]
      ,[HelpText]
      ,[ObjectProgID]
      ,[DefaultValueType]
      ,[LongStringSettings]
      ,[SettingsID]
      ,[LanguageSpecific]
      ,[DisplayEditUI]
      ,[ExistsOnModel]
  FROM [dbo].[tblPropertyDefinition]
  where Name = 'ParentEntries')

With 21 is the pkID of your content type in tblContentType.

Regards.

/Q

#138968
Sep 24, 2015 12:13
Vote:
 

Hi,

Ok that query solved the issue for the start page and product lists but now I get the same error message when trying to load some product pages and some product pages work, all products work on the product listing pages. I will debug some and see if I can see anything.

/Viktor

#138976
Sep 24, 2015 13:37
Vote:
 

You should compare between the [tblPropertyDefinition] table between your production database and development database. I suspect there might be other properties missing.

/Q

#138977
Sep 24, 2015 13:44
Vote:
 

Hi,

Ahh, ok you are right the same property was missing from content 42, 43 and 44 so adding them seems to have solved it for all products. Thanks!

Is there something corrupt in our test database or is it a bug in the upgrade scripts?

/Viktor

#138978
Sep 24, 2015 13:58
Vote:
 

I suspect it's an error in the database migration - when you transfer between databases those rows might be lost. I think the upgrade scripts won't touch those things - do you have an old version of database which has not been upgraded to check?

If it's an issue with our upgrade scripts (very unlikely, but still a possibility), let us know and we'll work on it right away.

Regards,

/Q

#138979
Sep 24, 2015 14:17
Vote:
 

Hi,

I just had an issue related to this matter. I got the same error in a Commerce 8.16.1 solution and found out 
that all my custom content models (defined in code) was deleted from the tblContent every time the Commerce Manager app-pool was recycled.

The models was then recreated when I recycled the app-pool for the CMS site. I resolved it by moving my models to a separate assembly and
then added them to the bin folder for both applications. Is this the correct way to do or should I somehow disable the 
assembly scanning for the Commerce Manager site?

Kind Regards,

Christer Heinbäck

#140774
Edited, Oct 29, 2015 16:49
Vote:
 

Hi,

So if I understand correctly, your typed content types are deleted because the assembly contains them was not in bin folder of Commerce Manager?

That sounds very strange. It should not behave that way. Make sure you have this in CM's web.config. enableModelSyncCommit should be false. 

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

Regards,
/Q



#140775
Oct 29, 2015 17:02
Vote:
 

Hi Quan,

My applicationSettings look a bit diffrent and the enableModelSyncComit attribute is missing:

  <episerver>
    <workflowSettings disable="true"/>
    <applicationSettings httpCacheability="Public" pageValidateTemplate="false" uiShowGlobalizationUserInterface="true" uiUrl="~/EPiServer/CMS/" urlRebaseKind="ToRootRelative" enableScheduler="false"/>
  </episerver>

I will try adding the attribute. Should I remove all other attributes?

Regards,

Christer

#140776
Oct 29, 2015 17:08
Vote:
 

Hi,

I don't think the other settings are needed. enableModelSyncCommit and enableScheduler should be there. and IIRC then uiUrl was required by Framework. 

/Q

#140777
Oct 29, 2015 17:15
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.