Errors when trying to setup second instance of Sitecore Commerce Habitat site using Solr in same machine but different set of website ports

When a second instance of Sitecore Commerce with Habitat is setup (in totally different set of ports) in the same machine, the following errors start popping up...


Error - 1:

Happens in the first instance, after installing second instance of commerce in a totally different set of ports.  If this is not related to multiple Sitecore Commerce Habitat Instance; the db index returns a null value. Check if Solr  Service is running. If Solr is not running, start it, also reset IIS and try searching. If Solr is already running, restart Solr service and try searching. If it doesn't work, try rebuilding the concerned index that the website points to. For instance, if your storefront points to Master DB, go to Indexing manager and rebuild just the master db index.

Server Error in '/' Application.

Value cannot be null.
Parameter name: sitecoreSearchResults

Description: An unhandled exception occurred.

Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: sitecoreSearchResults

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:


[ArgumentNullException: Value cannot be null.
Parameter name: sitecoreSearchResults]
   Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) +64
   Sitecore.Commerce.Engine.Connect.Search.SearchResponse.Create(CommerceSearchOptions searchOptions, SearchResults`1 sitecoreSearchResults, Func`2 getItemDelegate) +149
   Sitecore.Commerce.XA.Foundation.Connect.Managers.SearchManager.SearchCatalogItemsByKeyword(String keyword, String catalogName, CommerceSearchOptions searchOptions) +4137
   Sitecore.Commerce.XA.Feature.Catalog.Repositories.BaseCatalogRepository.GetChildProducts(CommerceSearchOptions searchOptions, Item item) +308
   Sitecore.Commerce.XA.Feature.Catalog.Repositories.ProductFacetsRepository.GetProductFacetsRenderingModel(String searchKeyword, Nullable`1 pageNumber, String facetValues, String sortField, Nullable`1 pageSize, Nullable`1 sortDirection, StringPropertyCollection propertyBag) +525
   Sitecore.Commerce.XA.Feature.Catalog.Controllers.CatalogController.ProductFacets(String searchKeyword, Nullable`1 pageNumber, Nullable`1 pageSize, String facetValues, String sortField, Nullable`1 sortDirection) +90
   lambda_method(Closure , ControllerBase , Object[] ) +434
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +35
   System.Web.Mvc.<>c__DisplayClass24_0.<InvokeActionMethodWithFilters>b__0() +80
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +466
   System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +466
   System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +524


Error - 2: Happens when a second instance of storefront is setup in totally different set of ports. As soon as the second instance is setup, the first instance throws errors. This error is thrown while trying to rebuild link databases.

Job started: RebuildLinkDatabasesIndex|System.NullReferenceException: Object reference not set to an instance of an object.
   at Sitecore.Commerce.Engine.Connect.DataProvider.ReadOnlyCatalogDataProvider.GetChildIDs(ItemDefinition parentItem, CallContext context)
   at Sitecore.Data.DataProviders.DataProvider.GetChildIDs(ItemDefinition item, CallContext context, DataProviderCollection providers)
   at Sitecore.Data.DataSource.GetChildIDs(ID itemID)
   at Sitecore.Nexus.Data.DataCommands.GetChildrenCommand.‏‪‬‪‍‏​‮‌‭​​‍‏‭‌‌‌‫‏‬​‪‫​‏‮(Item )
   at Sitecore.Nexus.Data.DataCommands.GetChildrenCommand.‌‫‬‬‮‌‏‍‫‪‪‪‫‪‭‍‬‪‭‭‫​‬‮(Item )
   at Sitecore.Data.Engines.EngineCommand`2.Execute()
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, ChildListOptions options)
   at Sitecore.Data.Managers.ItemProvider.GetChildren(Item item, SecurityCheck securityCheck, ChildListOptions options)
   at Sitecore.Data.Items.Item.GetChildren(ChildListOptions options)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.RebuildItem(Item item)
   at Sitecore.Links.LinkDatabase.Rebuild(Database database)
   at Sitecore.Shell.Applications.Dialogs.RebuildLinkDatabase.RebuildLinkDatabaseForm.Builder.Build()|Job ended: RebuildLinkDatabasesIndex (units processed: 1)




Reason: The possible cause is catalog node is missing child items (in one of the DBs and it mostly is the db that the first instance's Storefront was pointing to). On further analysis, could find that Template Overrides was missing actual items specified in this blog - https://andrewsutherland.azurewebsites.net/2020/03/20/sitecore-experience-commerce-resolving-site-catalog-association-lock/. Although the template overrides were corrected, the error affected other parts of the habitat content tree. Maybe try an IIS reset because that made the error go but wasn't permanent. Would comeback if switching over to the second instance and search for products.

Error - 3: Happens when trying to setup a second instance of Sitecore Commerce. Try to load content editor after switching over to Web db and the error is thrown. Used razl to load the web instance to check how the content tree looks and can see a lot of items missing in web db -

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.]
   Sitecore.Commerce.XA.Foundation.Upgrade.Services.UpgradeService.get_ValidUpgradeScripts() +133
   Sitecore.Commerce.XA.Foundation.Upgrade.Pipelines.ContentVersionWarning.Process(GetContentEditorWarningsArgs args) +187
   (Object , Object ) +8
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +489
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +235
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +21
   Sitecore.Shell.Applications.ContentManager.Editor.GetWarnings(Boolean hasSections) +323
   Sitecore.Shell.Applications.ContentManager.Editor.Render(RenderContentEditorArgs args, Control parent) +158
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.RenderEditor(Item item, Item root, Control editorsContainer, Boolean showEditor) +293
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.UpdateEditor(Item folder, Item root, Boolean showEditor) +479
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.Update() +549
   Sitecore.Shell.Applications.ContentManager.ContentEditorForm.OnPreRendered(EventArgs e) +191

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +132
   System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +146
   Sitecore.Reflection.ReflectionUtil.InvokeMethod(MethodInfo method, Object[] parameters, Object obj) +89
   Sitecore.Shell.Applications.ContentManager.ContentEditorPage.OnPreRender(EventArgs e) +143
   System.Web.UI.Control.PreRenderRecursiveInternal() +200
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7479

razl:

If this is not related to multiple Storefront instances, then the issue is, a publish needs to be done so, perform a publish. Now, load the content tree for the web db and items should load fine without any errors -

Next, point Storefront (/sitecore/content/Sitecore/Storefront/Settings/Site Grouping/Storefront)  Database to web db to check if habitat tree items load fine - sometimes has missing items. So, need to restore the same.

While still pointing to web db, try to search for a known product in the Storefront. The web db search should return blank results if the web index is not populated yet. Switch over to Indexing manager and just rebuild the web index -
After checking that search functionality is fine in the storefront, Ensure to point Storefront Database back to Master and publish.

Error - 4: Happens when creating a second instance of Sitecore Commerce habitat storefront (totally different ports) in the same machine.

Server Error in '/' Application.

Default Control Panel Storefront

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.InvalidOperationException: Default Control Panel Storefront

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:


[InvalidOperationException: Default Control Panel Storefront]
   Sitecore.Commerce.XA.Foundation.Common.Models.CommerceStorefront.get_ControlPanel() +383
   Sitecore.Commerce.XA.Foundation.Common.Models.CommerceStorefront.get_StorefrontConfiguration() +14
   Sitecore.Commerce.XA.Foundation.Common.Models.CommerceStorefront.get_IsSslEnforced() +16
   Sitecore.Commerce.XA.Foundation.Common.Pipelines.SecuredPageProcessor.Process(PipelineArgs args) +179
   (Object , Object ) +14
   Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +490
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists) +236
   Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
   Sitecore.Web.RequestEventsHandler.OnPostAuthenticateRequest(HttpContextBase context) +214
   Sitecore.Nexus.Web.HttpModule.‌‮‪‎‮‎‎‍‏‬‎‫‏‭‮‬‏‌‭‬‎‌‏‬‬‮(Object , EventArgs ) +414
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
   System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +220
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +94


The combination that caused the above error is:
Database: Web
Cache Html checkbox under Flags section is unchecked
Disable Browser Caching drop down is set to Yes


Changed Database from Web to Master, left other settings as-is and published the change to see the error go.

Comments

Popular Posts