Sitecore Commerce 8.1 nonsence errors and fixes

A short blog post for you to get these nasty errors fixed.

Weird nonsence #1

-2146233343, Commerce Server Configuration, 
Loading this assembly would produce a different grant set from other instances. (Exception from HRESULT: 0x80131401)
SiteConfigReadOnly:Initialize

Resolve:

I have no idea what is this, but you need to add the following thing in your web config:

<system.web>
  	<trust level="Full" legacyCasModel="false"/>

Nonsence #2

Server Error in '/' Application.

-2147217843, Commerce Server Configuration, Login failed for user 'WORKGROUP\MY-PC$'. SiteConfigReadOnly:Initialize

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: CommerceServer.Core.Runtime.CommerceException: -2147217843, Commerce Server Configuration, Login failed for user 'WORKGROUP\MY-PC$'. SiteConfigReadOnly:Initialize

etc, etc.

Resolve:

You might be running your website app pool using either Network Service or AppPoolIdentity, which is not enough for commerce. You need to set it to a user who has sysadmin and db_owner rights to the MSCS_Admin database – for example, your current administrator user identity.  S/O: link

I hope this helps

 

Advertisements

Sitecore Commerce 9 installation errors

During my latter installation of the Sitecore Commerce 9 with Robert Hock script, I had couple of errors that I wanted to share with you guys, to make sure it will eliminate numerous errors in the future.

So, here we go:

Error 1:

Install-SitecoreConfiguration : Cannot validate argument on parameter 'FilePath'. The " Test-Path $_ -PathType Leaf  " validation 
script for the argument with value 
"C:\inetpub\wwwroot\www.xyz.local\App_Config\Sitecore\ContentSearch\Sitecore.ContentSearch.config" did not return a result 
of True. Determine why the validation script failed, and then try the command again.
At D:\Commerce\SIF.Sitecore.Commerce.1.1.4\xyz Deploy-Sitecore-Commerce.ps1:200 char:5
+     Install-SitecoreConfiguration @params
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Install-SitecoreConfiguration

Fix:

Check that the path to your config file is correct, and the file is there.

Error 2:

 Detailed Error Information: 
   
    Module&nbsp;&nbsp;&nbsp;IIS Web Core 
    Notification&nbsp;&nbsp;&nbsp;Unknown 
    Handler&nbsp;&nbsp;&nbsp;Not yet determined 
    Error Code&nbsp;&nbsp;&nbsp;0x8007000d 
    Config Error&nbsp;&nbsp;&nbsp; 
Config File&nbsp;&nbsp;&nbsp;\\?\C:\inetpub\wwwroot\xyz.commerce-identityserver\web.config 
    
    Requested URL&nbsp;&nbsp;&nbsp;https://identityserver.xyz.local:443/connect/token 
    Physical Path&nbsp;&nbsp;&nbsp; 
    Logon Method&nbsp;&nbsp;&nbsp;Not yet determined 
    Logon User&nbsp;&nbsp;&nbsp;Not yet determined 
     
    Config Source: 
       -1: 
    0: 
 
 More Information: 
  This error occurs when there is a problem reading the configuration file for the Web server or Web application. In some cases, the 
event logs may contain more information about what caused this error. 
  View more information &raquo; 
   
 
 
At D:\Commerce\SIF.Sitecore.Commerce.1.1.4\Modules\InitializeCommerce\InitializeCommerce.psm1:89 char:17
+ ... $response = Invoke-RestMethod $UrlIdentityServerGetToken -Method Post ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

Fix:

  1. Check that the URL rewrite module is present (from the Microsoft WPI)
  2. Check that all of your instances are running on the HTTPS
  3. Verify that .Net Core is installed (my case) –  https://www.microsoft.com/net/download

Error 3:

When you click on the Business Tools in the Launchpad it leads to the localhost:4200

Fix:

Go to: /sitecore/client/Applications/Launchpad/PageSettings/Buttons/Commerce/BusinessTools and set the Link field value to your bizfix server address (https://bizfx.xyz.local/ – in my case)

Error 4:

When you open your Business Tools in the Launchpad, you see the following error:

Failed to load https://commerce-authoring.xyz.local/api/GetNavigationView(): 
Response to preflight request doesn't pass access control check: 
No 'Access-Control-Allow-Origin' header is present on the requested resource. 
Origin 'https://bizfx.xyz.local' is therefore not allowed access.

Fix:

Make sure that you have the correct bizfx url in the config.json of your commerce authoring:

\CommerceAuthoring_Sc9\wwwroot\config.json

In the AppSettings -> AllowedOrigins section, make sure that an entry to your BizFx’s URL is in the list!

By default it is localhost:4200, however, it can yield an error if you change it.

This setting is case-sensitive, means that if you have a https://MyBizFx.url, and you request it from https://mybizfx.url it won’t work, be careful.

The S/O post here answers this question as well.

Sitecore Prefetch configuration fails to load

Issue:

One day I was uprading my website to Sc 8.2 u2 and after all the steps were done, my sitecore couldn’t load, showing this exception:

[NullReferenceException: Object reference not set to an instance of an object.]
   Sitecore.Xml.Patch.XmlDomSource.get_NamespaceURI() +3
   Sitecore.Xml.Patch.XmlPatchHelper.MergeNodes(XmlNode target, IXmlElement patch, XmlPatchNamespaces ns) +118
   Sitecore.Configuration.ConfigPatcher.ApplyPatch(TextReader patch, String sourceName) +133
   Sitecore.Configuration.ConfigPatcher.ApplyPatch(String filename) +92
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +176

[ConfigurationException: Could not load configuration file: \Website\App_Config\Include\Prefetch\Common.config.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +379

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include\Prefetch for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +581
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +257

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include\Prefetch for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +480

[ConfigurationException: Could not scan configuration folder \Website\App_Config\Include for files.]
   Sitecore.Configuration.ConfigReader.LoadAutoIncludeFiles(ConfigPatcher patcher, String folder) +581
   Sitecore.Configuration.ConfigReader.GetConfiguration() +655
   Sitecore.DependencyInjection.ServiceLocator.ConfigureServiceProvider() +29
   Sitecore.DependencyInjection.ServiceLocator.get_ServiceProvider() +153
   Sitecore.DependencyInjection.SitecorePerRequestScopeModule..ctor() +13

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark) +138
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +105
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1481
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +191
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +27
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +82
   System.Web.HttpApplication.BuildIntegratedModuleCollection(List`1 moduleList) +229
   System.Web.HttpApplication.GetModuleCollection(IntPtr appContext) +1114
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +140
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +402
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +343

[HttpException (0x80004005): Exception has been thrown by the target of an invocation.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +579
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +112
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +716

 

I was not able to understand what’s wrong! All of my prefetch configs were fine and identical to ones from the vanilla instance…

So, I started digging into the sitecore patching code. Everything seemed fine, I mean, it is solid and straightforward. I was hopeless, but then…

Solution:

I realized that my Prefetch folder has moved under the /Include folder!

\App_Config\Include\Prefetch\Common.config

And that caused the issue with incorrect patching!

So, in order to fix that, I just had to move it back to /Include, and it worked.

SwitchMasterToWeb exception

Hi folks,

This is yet another blogpost about an error you can get after enabling the SwitchMasterToWeb config in your sitecore (8.1).

The exception looks like that:

Could not find configuration node: contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster

 


Exception Details: System.InvalidOperationException: Could not find configuration node: contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster

Stack Trace: 
[InvalidOperationException: Could not find configuration node: contentSearch/indexConfigurations/indexUpdateStrategies/syncMaster]
 Sitecore.Configuration.Factory.GetConfigNode(String xpath, Boolean assert) +483
 Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) +267
 Sitecore.Configuration.Factory.CreateFromReference(XmlNode configNode, String[] parameters, Boolean assert) +137
 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +109
 Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) +1013
 Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +552
 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +275
 Sitecore.Configuration.Factory.GetInnerObject(XmlNode paramNode, String[] parameters, Boolean assert) +1013
 Sitecore.Configuration.Factory.AssignProperties(XmlNode configNode, String[] parameters, Object obj, Boolean assert, Boolean deferred, IFactoryHelper helper) +552
 Sitecore.Configuration.Factory.CreateObject(XmlNode configNode, String[] parameters, Boolean assert, IFactoryHelper helper) +275
 Sitecore.Configuration.Factory.CreateObject(String configPath, String[] parameters, Boolean assert) +579
 Sitecore.ContentSearch.ContentSearchManager.get_SearchConfiguration() +266
 Sitecore.ContentSearch.SolrProvider.SolrContentSearchManager.get_Cores() +92
 Sitecore.ContentSearch.SolrProvider.CastleWindsorIntegration.WindsorSolrStartUp.Initialize() +44
 Website.Application.Application_Start(Object sender, EventArgs e) +11

This happens because the sitecore_list_index is referencing the syncMaster strategy while the default SwitchMasterToWeb config removes that strategy from configuration.

Solution: you should add the following patch to the SwitchMasterToWeb config in order to get rid of the list index on the delivery server:

 <index id="sitecore_list_index">
    <patch:delete/>
 </index>

 

What causes Tracker.Current initialization failure

Hi Folks,

Sometimes we may get this quite generic exception:

ERROR Application error.
Exception: System.InvalidOperationException
Message: Tracker.Current is not initialized
Source: Sitecore.Analytics
 at Sitecore.Analytics.Pipelines.StartAnalytics.StartTracking.Process(PipelineArgs args)
 at (Object , Object[] )
 at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
 at Sitecore.Analytics.Pipelines.StartAnalytics.StartAnalyticsPipeline.Run()
 at Sitecore.Mvc.Analytics.Pipelines.MvcEvents.RequestBegin.StartTracking.Process(RequestBeginArgs args)
 at (Object , Object[] )
 at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
 at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
 at Sitecore.Mvc.Routing.RouteHttpHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
 at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
 at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

I have created this blog post to summarize all the possible reasons of this exception in one single place.

#1 Analytics host name

Look up for the mismatch of the Analytics.HostName and site host name in your Sitecore.Analytics.Tracker.config

The Analytics.HostName setting value has to match your website hostname in SiteDefinition.config file.

#2 Cluster names (Thanks to @Jose Dominguez)

If you have a load balanced environment with multiple CDs, you each server must be configured to have a unique cluster name.

This is controlled by the Analytics.ClusterName setting in the Sitecore.Analytics.Tracker.config.

<setting name="Analytics.ClusterName" value="default-cd-cluster" />

A quote from the documentation

If you are creating a cluster of content delivery servers, use your domain name when naming the content delivery cluster.

For example: value="cluster1.domain.com"

Repeat this for each node in the cluster.

For a single content delivery server, use the domain name of the server instead.

#3 Contact Facet Factory error

This usually happens when your custom facet definitions are failing to initialize, some common reasons:

  1. Facet class does not fully/partially implement the facet interface

You may also see the below exception in your log files:

ERROR Cannot create tracker.
Exception: System.ArgumentException
Message: The specified type is not a valid facet type.
Parameter name: facetType
Source: Sitecore.Analytics.Model
 at Sitecore.Analytics.Model.Framework.ModelFactory.CreateFacet(Type facetType)
 at Sitecore.Analytics.Model.Framework.Faceted.AddFacet(String name, Type type)
 at Sitecore.Analytics.Model.Framework.ModelFactory.CreateContact(ID id, IReadOnlyDictionary`2 facets)
 at Sitecore.Analytics.Data.ContactFactory.Create(ID id)
 at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbContactStorage.TryLoadContact(ID contactId, String identifier, IContactFactory factory, LeaseOwner leaseOwner, TimeSpan leaseDuration, Int32 maxAttempts)
 at Sitecore.Analytics.Data.DataAccess.MongoDb.MongoDbDataAdapterProvider.TryLoadContact(ID id, IContactFactory factory, LeaseOwner leaseOwner, TimeSpan leaseDuration)
 at Sitecore.Analytics.Data.ContactRepository.TryLoadContact(Guid id, LeaseOwner leaseOwner, TimeSpan leaseDuration)
 at Sitecore.Analytics.Tracking.ContactManager.TryLoadContact(Guid contactId, Int32 lockDurationMinutes, Boolean exclusive)
 at Sitecore.Analytics.Pipelines.EnsureSessionContext.LoadContact.Process(InitializeTrackerArgs args)
 at (Object , Object[] )
 at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
 at Sitecore.Analytics.Pipelines.EnsureSessionContext.EnsureSessionContextPipeline.Run(InitializeTrackerArgs args)
 at Sitecore.Analytics.DefaultTracker.EnsureSessionContext()
 at Sitecore.Analytics.Pipelines.CreateTracker.GetTracker.Process(CreateTrackerArgs args)
 at (Object , Object[] )
 at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
 at Sitecore.Analytics.Tracker.Initialize()

#4 WFFM Form is referencing a facet that can’t be initialized

This is essentially a subset of #3.

Check that your WFFM form and its save actions does not reference the unexisting contact facet! This happened to me when I eventually renamed facet, but forgot to update my form

More?

Please, feel free to comment this post and share some cases that you experienced, so that we could gather all of the related issues in one place.

Thanks

Fortis Exception: Value cannot be null. Parameter name: field

Hi Folks,

This is another common issue that I face on my local dev environment frequently when using Sitecore Fortis engine.
Sometimes you may get this kind of exception:

Value cannot be null.
Parameter name: field

Description: An unhandled exception occurred.

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

Full stacktrace:

[ArgumentNullException: Value cannot be null.
Parameter name: field]
   Sitecore.Diagnostics.Assert.ArgumentNotNull(Object argument, String argumentName) +63
   Fortis.Model.Fields.FieldWrapper..ctor(Field field, ISpawnProvider spawnProvider) +37

[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.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +329
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark) +1499
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +191
   System.Activator.CreateInstance(Type type, Object[] args) +37
   Fortis.Model.ItemWrapper.GetField(String key, String lazyFieldsKey) +330

Solution: This usually happens when you rebuild your model, but forgot to publish your updated templates. Try to smart publish everything and it should start working.