Monday, July 18, 2016

Sitecore commerce required license missing error

After upgrading to Sitecore 8.1 the following error message may start appearing in the content editor:
Required license is missing.
You require one of the following licenses to use the Sitecore Commerce Connect module. 'Sitecore.Commerce.Connect' or 'Sitecore.Commerce.ConnectPartner'

The solution to suppressing this error message involves removing the Sitecore.Commerce.Pipelines.ContentEditorLicenseWarning processcor pipeline. The following patch file will delete the element, however it should be run last so include it in a z folder in App_Config.

<configuration xmlns:patch="">
        <processor type="Sitecore.Commerce.Pipelines.ContentEditorLicenseWarning, Sitecore.Commerce">
          <patch:delete />

Friday, July 8, 2016

Sitecore scheduled tasks not running as expected

On a Sitecore implementation some key scheduled tasks (set in the content editor rather than agents), would run around the expected time in most cases. However every so often there would be a major delay in their running (and as emails were sent it was noticeable what time it was kicked off).

After investigating the logs, I noticed that in the periods where the custom scheduled task was not being kicked off, a system task was running. The system task Rebuild Suggested Tests Index which relates to content testing (crawls the database and gives candidates for content testing - a/b testing). It was set to run once daily and due to content volume would take anywhere for 5 to 7 hours to run, of course not begin asynchronous it would hold up all other tasks.

The solution here was to set it to run weekly or to set it to be asynchronous.

Wednesday, July 6, 2016

Sitecore errors on a scaled environment

On a scaled Sitecore 8.1 environment with two content delivery servers and one content management server, I followed the Config_Enable-Disable_Sitecore_8.1_upd3.xlsx spreadsheet to disable/enable the required configuration files. The following errors started appearing in the content delivery logs.
Could not find configuration node: contentSearch/indexConfigurations/defaultFxmLuceneIndexConfiguration
This error required that Sitecore.FXM.Lucene.DomainsSearch.DefaultIndexConfiguration.config (found in App_Config\Include\FXM) be enabled, even though it was marked to be disabled on CD servers.
Invalid cast from 'System.String' to 'Sitecore.Analytics.Aggregation.Data.DataAccess.ICollectionDataProvider2'.
This error may cause images not to load along with other features such as search. The fix for this is to keep Sitecore.Analytics.Reporting.config (found in App_Config\Include) enabled, even though it was marked to be disabled on CD servers.

These issues were found using the Sitecore Habitat solution.

Tuesday, July 5, 2016

Sitecore session errors with MongoDB

An interesting issue was reported on a Sitecore environment where users were able to browse to several pages, but eventually the website would stop responding to requests (and it appeared as if the server was too busy to respond). However if cookies were cleared on the user's machine, they could browse for a bit before not getting requests back again.

In this instance the shared/private sessions were being stored in MongoDB. The following error was appearing in the logs:
ERROR Application error.
Exception: System.Web.HttpException
Message: Exception of type 'System.Web.HttpException' was thrown.
Source: System.Web
   at System.Web.HttpAsyncResult.End()
   at System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(IAsyncResult ar)
Nested Exception
Exception: MongoDB.Driver.MongoDuplicateKeyException
Message: WriteConcern detected an error ''. (Response was { "ok" : 1, "code" : 11000, "err" : "E11000 duplicate key error collection: session.sessions index: _id_ dup key: { : { s: \"j0lvazyxndl5ihfldr0zzce2\", a: \"private\" } }", "n" : NumberLong(0), "updatedExisting" : false }).
Source: MongoDB.Driver
In our instance we traced the error back to a corrupted MongoDB instance (which is a post for another day), and we moved sessions over to SQL Server to resolve the issue. However if you are seeing this error these are some configurations to check.
  1. Inside the web.config the <sessionState> element is where private sessions are defined.
  2. Inside Sitecore.Analytics.Tracking.config file is where shared sessions are defined
  3. Inside ConnectionString.config is where the connection string for any session databases (MongoDB or SQL Server) should be.
If any of these session configurations are using InProc in an environment with multiple servers (content delivery scaled environments for example) you will have a problem if the load balancer is not using sticky sessions (ensuring the visitor always visits the same server). In these sorts of environments its recommended to use a shared session source (MongoDB or SQL Server).

Sitecore search inconsistencies in the result URLs

I noticed on a Lucene search implementation in Sitecore that there were some inconsistencies around the URLs being generated. In some cases spaces where replaced by dashes and in other cases they were not. This was a tricky issue because some of the content names (and therefore paths) included dashes.

of course in the Sitecore.config file there was an encode name replacement to replace all dashes in URLs with spaces.
<replace mode="on" find=" " replaceWith="-"/>
However the results weren't showing until the EncodeNames element was set in the UrlOptions when generating the link with the link manager.
itemUrl = Sitecore.Links.LinkManager.GetItemUrl(item, new UrlOptions { AlwaysIncludeServerUrl = true, LanguageEmbedding = LanguageEmbedding.Never, EncodeNames = true});

Sitecore search ashx is appearing in search result URLs

I noticed that in some cases a Lucene search that I had built in Sitecore was generating URLs that contained a .ashx extension for PDF files in some cases and .pdf in others.

There is a setting in the Sitecore.config file which controls which extension will be shown for media library URLs. The setting is Media.RequestExtension and by default will be set to ashx.
<setting name="Media.RequestExtension" value="ashx"/>
Using a patch file (or editing directly), simply set this to an empty value to ensure media library content is served up using the correct extension.

However in my case, this did not resolve the issue... Some items were still coming through with .ashx and there was no content differences that could cause this issue. Ultimately setting IncludeExtension in the MediaUrlOptions did solve it:
itemUrl = MediaManager.GetMediaUrl(item, new MediaUrlOptions { AlwaysIncludeServerUrl = true, IncludeExtension = true});

Friday, July 1, 2016

User/anonymous generated content in Sitecore

User generated content from site visitors might be as simple as a comment on a news article, or more complex such as the submission of structured content (a community venue listing for example). The only question then becomes how to handle the user/anonymous generated content in Sitecore.