Friday, January 19, 2018

Sitecore Lucene not returning results for some languages

After expanding a Sitecore 8.1 site to offer content in multiple languages there was a strange error where the search in some languages (pt-BR in particular) would not return any results. This was happening even with a wildcard search that should return all results.

I checked the physical index (using version 3.5 of the Luke tool) and confirmed there were documents indexed with the target language (and these were not opted out of search results).

Luke tool shows the target language indexed.
The original code was using a where clause to filter based on the context language:
.Where(x => x.Language == Sitecore.Context.Language.Name)
Which was not working for some reason, so I tried changing the code to then get results based on culture:
searchItems = context.GetQueryable<SearchResultItem>(new CultureExecutionContext(culture))
After this change the search was returning items in all languages as expected.

Thursday, January 18, 2018

Sitecore xConnect - access to the registry key Global is denied

After checking my xConnect logs to ensure all was running smoothly the following error was present:
[Error] Access to the registry key 'Global' is denied.
System.UnauthorizedAccessException: Access to the registry key 'Global' is denied.
The fix for this error is to simply add the identity of the application pool that the xConnect site uses to the local group: Performance Monitor Users.

Performance Monitor Users group
In my case this user was IIS AppPool\sc9test_.xconnect - with the part following IIS AppPool being the name of the application pool.

Wednesday, January 17, 2018

Sitecore 9 analytics data not loading

After installing a fresh copy of Sitecore 9, I noticed that none of my Experience Analytics or Experience Profile data was showing.

Sitecore 9 - Experience Analytics errors
Sitecore 9 - Experience Profile errors
Looking into the developer tools console in Chrome I notice the following error:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
This was for an analytics API call: http://MyDomain/sitecore/api/ao/v1/aggregates/latest-visitors?&pageSize=20&pageNumber=1&sort=LatestVisitStartDateTime%20desc

Sitecore logs files were quite full and the following stood out:
Exception: System.IO.IOException
Message: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
Source: System
   at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
   at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
Nested Exception
Exception: System.Net.Sockets.SocketException
Message: An existing connection was forcibly closed by the remote host
Source: System
   at System.Net.Sockets.Socket.EndReceive(IAsyncResult asyncResult)
   at System.Net.Sockets.NetworkStream.EndRead(IAsyncResult asyncResult)
It appeared to be an error in connecting with xConnect. I tried to load the xConnect URL in my browser and the site would not load. Looking at the certificate that my xConnect was configured to use, I noticed that it was issues to a different domain name (sc9test_.xconnect instead of sc9test_.xconnect_client).

After changing the binding in IIS, adding it to my local hosts file and updating the connection string in Sitecore, the analytics errors disappeared.

The xConnect site would also load in my local browser as expected:
Sitecore xConnect loading in browser

Friday, January 12, 2018

Planning, preparing and performing a Sitecore upgrade

With the feature set of the Sitecore Experience Platform continuing to grow and improve with each new version, you definitely wont want to get left behind. It's also worth noting that the longer you leave the upgrade (the further you get behind) then the longer in terms of time, cost and difficulty the upgrade is likely to be.

This post is going to be a general overview of the upgrade process that will contain learnings from the Sitecore upgrades I have undertaken.

Planning the upgrade path

The first step is to head over to the Sitecore developer site, and locate the upgrade guide for the version of Sitecore you wish to upgrade to.

Sitecore upgrade guide download
In this case I am looking to upgrade from version 8.1 (initial) to 9 (update 1), so I download the upgrade guide for Sitecore version 9 (update 1). Then take a look at the prerequisites:

Sitecore upgrade prerequisites
In this case, I can upgrade directly from my current version. If however I was on version 8.0, then I would need to upgrade to 8.1 before going to 9 (again the upgrade guide would be downloaded for 8.1). This will then give us the upgrade path for the CMS. Effectively you are working backwards from the version you wish to end up on until you hit your current version.

The same can be done with any modules which may be installed (WFFM, EXM, SXA, etc.).

Preparing for the upgrade

Before undertaking the upgrade there are a few steps that need to be completed:
  1. Download the upgrade guide for each Sitecore version and module to be installed.
  2. Download and extract upgrade packages for each Sitecore version and modules to be installed.
  3. If required download an upgrade files required for Sitecore upgrade packages (such as SQL scripts or configs).
  4. If required download the update package for the update installation wizard.
  5. Backup the environment (database and servers) to be upgraded.
  6. Create a source control branch for the version of Sitecore you are upgrading to. Once you upgrade to a given version on your local environment, you will need to update custom code to work with that version (DLL and code changes).
You can now create an organized folder structure of the packages to install:

Top level folder structure for Sitecore upgrade
Expanded folder structure for Sitecore upgrade
In the case of the production upgrade, you may wish to clone the production environment, and simply switch the DNS once the upgrade has been validated.

Complete the upgrade

The upgrade guide will cover the required steps to upgrade the Sitecore CMS or a given module, however the likely process will be as follows (at a high level):
  1. Run a SQL script on the Sitecore databases.
  2. Install an update for the update installation wizard. This is the tool which takes the update file and runs through it - yes it update itself.
  3. Install the update package.
  4. Fix any conflicts (such as a configuration file which was edited manually and needs to be replaced with the upgraded one).
  5. Deploy any custom code.
  6. Perform a full publish.
These steps will need to be followed on all servers in a given environment (CD or CM, etc.). Once you have installed the Sitecore CMS update, then you would install all the required update packages for any module(s) you have.

Tips for a Sitecore upgrade

  1. Create backups of the IIS web site root along the way.
  2. With major upgrades there may be a lot of code changes required in your custom solution.
  3. Third party tools such as Glass Mapper or TDS may also need to be upgraded (in your code solution).
  4. When you have two identical servers (such as two CD servers behind a load balancer) you can upgrade one and copy the update web root to the other. Ensure there are no differences between the web roots first.
  5. Always leave extra time in any estimates you make, something you don't consider is likely to come up.
  6. Always upgrade a local development environment first, this also gives you a chance to upgrade your custom code solution.
  7. Check the logs after an upgrade for anything that may have arisen.
  8. Check for any broken links after an upgrade - using the admin tool.
  9. Depending on the size/complexity of an upgrade a smoke test right through to a full regression test may be needed. 
  10. Progress the upgrade through each environment (development -> staging -> production ...), testing along the way.


This was a short and simple post to cover off several areas which should assist someone in completing their first upgrade. Practice makes perfect, so don't be afraid to back up a local Sitecore environment and give it a go - if all else fails you can blow it away and restore the backup.

Sitecore SXA page appearing as $name in navigtation

A strange error came up on a Sitecore web site built using the Sitecore Experience Accelerator. A footer navigation item was appearing as $name (the display text), and linked off correctly to the page.

Looking at the page in the content editor, a yellow message appeared saying: If you publish now, the selected version will not be visible on the web site as it is unpublishable.

Sitecore item unpublishable
This can be resolved (assuming the item should be published and appear in the footer) by going to the publish ribbon item and selecting change.

Publish ribbon > Change
Then once the popup modal appears, ensure that the publishable checkbox is checked. Then publish the item and the $name issue is resolved.

Publishing Settings

Tuesday, January 9, 2018

Sitecore SQL Server timeout on full publish

After completing a Sitecore upgrade, and attempting to run a full publish, it would not complete and instead ended up with the following error:
Job started: Publish to 'web'|#Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlClient.SqlException: Execution Timeout Expired.  The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out
   --- End of inner exception stack trace ---
Sitecore full publish times out
Inside the Sitecore.config file (Website\App_Config) is a setting called DefaultSQLTimeout. In my case this was set to 5 minutes, by increasing this (temporarily) to 15 minutes the full publish was able to complete without any issues.