Skip to main content

Posts

Showing posts with the label Sitecore

Solr Service in Paused State during Sitecore installation

 The Problem I was working on Sitecore installation on a new machine. Everything was running smooth but the SOLR service always ended up in PAUSED state.  The Research I tried stopping the service and then starting it using NSSM multiple times but it did not help. Then I thought of removing and recreating the service but again no help. And then it was followed by a machine restart and the service still ended up in PAUSED state.  I started googling about this issue and found answers suggesting that may be JAVA_HOME environment variable is not set or may be JAVA is not installed. I opened my command prompt to execute  echo %java_home% to get value for JAVA_HOME environment variable and it returned a blank value. This proved there is definitely an issue with JAVA setup on my new machine. Next,  I executed  java -version in cmd prompt and I found that the new machine is using Microsoft build of openJDK   instead of JRE (snapshot below) It was found that new machine is using openJDK because

Sitecore PowerShell script to update Allowed Controls field in placeholder settings

The Problem We created a new module (or component or rendering) in Sitecore and we needed to add this rendering to Allowed Controls field in the placeholder settings in Sitecore. It is also required to allow this rendering on all the placeholders in Sitecore so that content authors have the ability to add this rendering on pages in experience editor. Below is a snapshot of the field that is used for this- If the placeholders were in limited number, it would have been an easy manual job. But we had more than 20 placeholders for different page types. And we were in a process of introducing several new modules which meant this task is going to be repetitive and time consuming. So, to save time and for accuracy, we decided that we should develop a simple PowerShell script to make this process simple. The Solution We developed below script -  $placeholders = Get-ChildItem "/sitecore/layout/Placeholder Settings/<path where your placeholders are present>" -recurse Foreach($pla

Sitecore Content Serialization error - The container is defined twice

The Problem If you use Sitecore Content Serialization to serialize your Sitecore items into yml files (and if you use Leprechaun to generate/update item models automatically in our solution), there are chances you may stumble upon the error as in the snapshot below -  The Solution If you have used Sitecore Content Serialization, then you will know that it makes use of a module.json file in which you specify details about what items to serialize. It usually looks something like this -  {   "namespace": "Feature.Sample",   "items": {     "includes": [       {         "name": "templates",         "path": "/sitecore/templates/Feature/Sample"       },       {         "name": "renderings",         "path": "/sitecore/layout/Renderings/Feature/Sample"       },       {         "name": "buttons",         "database": "core",         "

Publishing Service Failed: Could not resolve stores 'web' of type source

Problem While trying to publish an item using Sitecore Publishing Service, the publish job shows status as Failed (check snapshot below) and when user clicks on it to get more details, it says -  Could not resolve stores 'web' of type source Solution We checked the logs and it said -  2023-10-09 09:31:32.560 -04:00 [Error] Error during publish of 443f1620-188b-4f39-a9c8-ef284d9a6c6b - Error: "Could not resolve stores web of type source" System.Exception: Could not resolve stores web of type source at Sitecore.Framework.Publishing.Data.DefaultStoreFactory.CreateSources(DataAccessContextType dataAccessContext, String[] names) at Sitecore.Framework.Publishing.PublishContext..ctor(IStoreFactory storeFactory, PublishOptions publishOptions, Guid jobId, DateTime started) at Sitecore.Framework.Publishing.PublishContextFactory.Create(IStoreFactory storeFactory, PublishOptions publishOptions, Guid jobId, DateTime started) at Sitecore.Framework.Publishing.Tasks.Publi

String Interning in Sitecore

I am always looking at different ways of optimizing application resources in Sitecore. After all, low resources means low cost!! I came across the concept of String Interning and I got interested into it. Next, I was thinking how can I make use of it in my Sitecore instances. I started digging little bit and I found Sitecore is smart enough to already make use of it. I will share some of the findings in this post. What is String Interning?  In computer science, string interning is a method of storing only one copy of each distinct string value, which must be immutable.  What this means is if you have a string object str1 with value "Hello" and then if your code initializes another string object str2 with same value "Hello", string interning will prevent creation of second object for str2 as String Constants Pool already has a string object with same value. It will assign the reference of str1 to str2 and str2 will reuse the object that was created for str1. This obv

Script to read contents of media files attached to Sitecore media library items

Ever wondered how can we read contents of files uploaded to media library without rendering them? Recently, we needed a PowerShell script to read the content of our SVGs and create a list of SVGs which contained a pattern in them. After a little research, I came up with this script -  $item =Get-Item -Path "/sitecore/media library/<filepath here>" $mediaItem = New-Object 'Sitecore.Data.Items.MediaItem' $item; $blobField = $mediaItem.InnerItem.Fields["blob"] if($blobField){         $blobStream = $blobField.GetBlobStream()         if($blobStream){             try                 {                 $contents = New-Object byte[] $blobStream.Length                 $blobStream.Read($contents, 0, $blobStream.Length) | Out-Null             }              finally              {                     $blobStream.Close()                 }             $fileText = ([System.Text.Encoding]::Default.GetString($contents))         } } In the above script, $fileText will co

Animated GIF files become not animated after resizing in Sitecore

Maintaining websites in Sitecore helps you discover interesting issues. In this blog, we discuss one such issue :) The Problem We all know that Sitecore has the ability to resize images based on the query parameters that are supplied in a media item's URL. You must have already figured out that animated GIF files become not animated after resizing in Sitecore (it is in this blog's title itself).  Wondering why it happens? According to Sitecore in  KB1001735   -  There is no built-in .NET functionality to resize a GIF file and keep its properties (for example, the delay between frames). In this case, only the first frame of the file is displayed. As a result, the animated GIF file might become not animated after resizing it using Sitecore.   What this means is if you have a GIF like this -  and if you want to resize it in Sitecore, it will appear like this -  Sitecore has suggested a fix for it in the KB article which skips resizing of GIF files to prevent GIF files from becomin

PublishJobCleanUp and PublishOperationAgeBasedCleanUp tasks in Sitecore Publishing Service

We have been using Sitecore Publishing Service for a while now and it has helped to reduce the publishing time. It takes publishing operations to a separate server which is good architecture. Any hiccups on the publishing service side don't impact our Sitecore servers directly  and we have been enjoying it so far. The Problem.. We have faced few bumps as well on our publishing service ride. We have been facing an issue where our Sitecore Publishing Service will get unresponsive after a week of acting normal. This blocks publish operations, publishing dashboard flashes errors and content stops getting pushed to live servers. As a quick fix, we restart the publishing service and that helps to clear the clutter. We have been working on finding a permanent fix for it. The Solution.. (for now) We got in touch with Sitecore Support. After analyzing our application, logs etc. they suggested that our application publishes more than what Sitecore publishing service's  default settings a

Sitecore Indexing Manager stops showing indexes due to expired SSL certificate in SOLR

The Problem While working on Sitecore, it may happen that one of your SSL certificates may expire after some time. This can cause functionalities to break.  For e.g., I encountered a problem where the SOLR search functionalities on my local Sitecore instance stopped working. You may be having similar problem if you face following issues -  when you search a GUID in Content Editor to locate an item, it would not return any result and say that an exception has occurred.  when you try to rebuild my SOLR indexes using Rebuild Search Indexes in Control Panel, the dialog did not list any of my SOLR indexes. The Research I looked into the logs to find the root cause to the problem and found following warnings -  128216 15:40:08 WARN  IsOnline: Test connection has failed with an exception. Type: 'SolrConnectionException', Message: 'The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.' I tried to load my local SOLR instance

Sitecore PowerShell script to remove rendering parameters

This blog introduces you to concept of updating rendering and rendering parameters using Sitecore PowerShell Extension. If you are maintaining a web application based on Sitecore with loads of content items, you may be familiar with content cleanup or update requests that comes from business. This is where Sitecore PowerShell Extension comes very handy and saves our life. A little background .. We were using Media Framework based connector for Brightcove videos integration in Sitecore 8.2 website. When we upgraded to Sitecore 10.1, connector for Brightcove videos integration was also migrated from Media Framework to Data Exchange Framework. So far so good. But we realized that Media Framework based integration involved storing some video and video player related data in rendering parameters as in snapshot below -  We did not see these rendering parameters getting used anymore in Data Exchange Framework based integration. Hence, it was decided to remove these rendering parameters from r

Update CICD scripts to new Sitecore NuGet URLs to avoid interruptions

If you are not already aware, Sitecore is moving its public feed from sitecore.myget.org to a different feed provider on November 30, 2023. The URL of the new public feed is: https://nuget.sitecore.com/resources/v3/index.json The URL for the internal artifact provider is: https://cloudsmith.io/~sitecore/repos/resources/groups/ The custom NPM feed will move from https://sitecore.myget.org/gallery/sc-npm-packages to the public NPM provider https://www.npmjs.com/ Both the original MyGet and the new public feeds are available now. After November 30, only the new NuGet and NPMJS public feeds will be available. Sitecore strongly recommends that all customers and partners update their CI/CD processes and build scripts to use the new public feeds as soon as possible to avoid interruptions beyond November 30, 2023. The above information is shared by Sitecore  here . How this can impact you? This can impact you if you are making use of these URLs. Such URLS are usually used in Build/Release (CI/

Is sxa_site cookie necessary for Sitecore website

Is sxa_site cookie necessary for Sitecore website? If you are working on a requirement for cookie consent of your site, this question will definitely strike your mind. You would like to know that "sxa_site" cookie is not really necessary for Sitecore SXA websites. According to Sitecore support team, the website still works in case you remove the cookie. So, this is not one of the necessary cookies for cookie consent. Ever wondered what sets this cookie for Sitecore SXA sites? Following code in snapshot is used to set the cookie in Sitecore.XA.Foundation.Multisite.Pipelines.HttpRequest.StoreSiteNameInCookie processor- Even knowledge of such little things can be highly useful when handy at time. Hope you like it!!

Sitecore bug 520726 - EE strip HTML tags for Single-line text if we edit and save other fields

 The Problem We are on Sitecore 10.1 update 2. We had a business requirement to allow HTML tags in single-line text fields so that page headings and subheadings can have superscripts etc. in them. We understand that for security reasons, Sitecore encodes all the HTML tags entered into the fields. This needed us to make sure to add logics in our backend to ensure that the HTML tags gets decoded so that they can be rendered at the front end. So far so good and everything went as planned. After the customization, we were able to see the HTML tags added to single-line text fields getting rendered properly at front-end.  Then where is the problem? We did a few more edits on the page and observed that HTML tags added to Single-Line text fields earlier got stripped off during subsequent edits and page saves. Here is a video of the issue -  The Research This issue was also reproducible on sandbox instances. This proved that it was not due to any of the customizations done in our solution. We r

Failed to start service Sitecore XConnect Search Indexer- An error while installing Sitecore 10

The Problem This issue can happen to developers who are trying to install the Sitecore 10 instance. Developers may start getting following error -   "Failed to start service Sitecore XConnect Search Indexer"  When developers will check in xConnect event log, they will observe that the exception is about a missing required. Below are entries in the log file for the same (XConnect.log file) -  2023-06-12 10:03:15.286 +05:30 [Error] Failed to start the indexer host System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Sitecore.Nexus.Licensing.LicenseException: Required license is missing: Sitecore.xDB.Base    at ‭‪‮‎‌‪‎‫‬‌‮​‍‪‎‬‎‏‌‫‭‮‮.(‬‮‍‎‍​‭‎‮‮‪‏‮‏‌‪‎‭‌‍‭‪‬‮ , String )    at Sitecore.XConnect.Configuration.Extensions.InitializeLicenseCheck(IServiceCollection collection, String licenseFileOrXml)    at Sitecore.XConnect.Configuration.Extensions.UseXConnectServiceInitializationConfigurati

Testing Sitecore with Selenium NUnit

Pretty much all the Sitecore development is happening in Agile. Hence, code is released more frequently to live servers than it used to be in waterfall models. This also means there is a need of testing after each release. A regression in QA environment and a smoke test in STAGE environment is required to ensure that the development done in sprint does not break any thing else. This is the job of QA team. Why are we talking about it here? If your team is testing Sitecore functionalities manually, then it is wise to automate at least some of your test cases. Testing some basic Sitecore functionalities like login, publishing etc. manually is something QA team can easily do but when one needs to automate it, QA developers needs to have some knowledge of Sitecore also and vice-versa.  Hence, here is a simple blog on guiding how to develop some basic automated test cases in Sitecore. Lets get started.. In this blog, I am taking example of a basic scenario which includes testing that your us