This blog is based on one of my recent experience where it was required to disable On Demand Loading of Model Configurations in an existing Sitecore 9 application using Glass.Mapper.Sc 5.
Majority of Model configurations in this application were done via Auto mapping and Attribute configurations.
I am sharing here learning I had and some of details regarding the Glass.Mapper.Sc configurations.
Setting Up the Context: Before mentioning the Steps I did for disabling On Demand loading – Let’s understand some details with respect to Model Configurations and their loading details.
What are the available Model Configurations
In Glass.Mapper.Sc – we have 3 ways to configure our mapping Model (Model Configurations)
What is On-Demand Loading : Out of Box – Glassmapper supports On-Demand Loading – which means all the Model configurations will be loaded as and when Model call is made in the application.
Why would we need to disable On-Demand Loading.
to ensure all the Model configurations are loaded as part of application startup.
Would be handy for any Model Validation during application start up.
To avoid referred types being loaded incorrectly.
How to load Model Configurations explicitly:
via SitecoreAttributeConfigurationLoader : for Attribute Configurations defined in GlassMapperScCustom.cs
via SitecoreFluentConfigurationLoader : for Fluent Configurations defined in GlassMapperScCustom.cs
explicitly set OnDemandMappingEnabled as “false” in App_Start\GlassMapperScCustom.cs
Define Attribute Configuration Loader in App_Start\GlassMapperScCustom.cs
Make sure all Models(Class/Interface) in the assembly has [SitecoreType] attribute defined.
This is required as we sometimes add field level attribute mapping and do not add SitecoreType attribute on Class/Interface.
In the application I was working had majority of configurations defined via auto-mapping (without any attribute configurations)- So next step was to go in each of such class/Interface and add attribute : [SitecoreType(AutoMap =true)] .
Field (which are auto-mapping enabled )- can be left as is.
Above 2 steps are requied as SitecoreAttributeConfigurationLoader looks for [SitecoreType] attribute while loading the Model configurations during application start up.
Without [SitecoreType] defined : class/interface is ignored, even if the properties have attributes defined.
The other option is to use Fluent Configurations for mapping Model as using Fluent Configuration ensures Configuration is loaded during application start up.
I know I am quite late. – “Better Late than Never” – This is what I said myself when I started exploring Sitecore 9 since last 1 week.
Had some glitches as well during my installation with initial version (Sitecore Experience Platform 9.0).
Many Thanks to below blogs/tutorials which helped me in my way, as and when I was stuck at various steps.
Grab the sitecore license file(license.xml) and place it in your setup folder as well.
This is how the setup folder (D:\InstallSitecore9) should look like now-
Setup SQL Server User – In past for all Sitecore installations I have been using sa user credential. In this step I will be setting up a standard user for all our Sitecore installations(having a ‘sysadmin’ role).
Open SSMS (SQL Server Management Studio) and connect to your local database.
Go to Security -> Login -> Add new Login
Your login name – I have given – “sclogin” for me.
Set your password.
Un-check Enforce Password policy.
From Server Roles – Give it a “sysadmin” server role and Click Ok
Reconnect with newly created user – “sclogin” to verify if user is created successfully.
Enable Contained Database Authentication- script is taken from Sitecore installation guide.
Launch MS SQL Server Management Studio and log in as an administrator
Run the following new query: – Can grab .sql file.
sp_configure 'contained database authentication', 1;
At last – Now we are ready to run SC 9 installation script.
I have taken the script from SC9 installation guide and placed it in my setup folder – installsc9.ps1 . You can grab script I used from here: installsc9.ps1
Update all of the parameters accordingly in power shell script file- installsc9.ps1
$prefix = "learnsc9" ==> name for your sitecore instance
$PSScriptRoot = "D:\InstallSitecore9" => setup folder which you have created in Step 3
$XConnectCollectionService = "$prefix.xconnect"
$sitecoreSiteName = "$prefix.sc"
$SolrUrl = "https://localhost:8983/solr" => SOLR url - which I have setup in Step 1 and 2.
$SolrRoot = "D:\SOLR\solr-6.6.2" => SOLR root folder which I have setup in Step 1.
$SolrService = "solr662" => SOLR service name which I have setup in Step 1.
$SqlServer = "LAPTOP-FT2VPMF2\SQLDEV" => Connection to my local database.
$SqlAdminUser = "sclogin" => new login user which was created as part of Step 10
$SqlAdminPassword="passwordforsclogin" => password which was setup as part of Step 10
Open Windows Power shell ISE as an administrator
Lets import both modules(SitecoreInstallFramework and SitecoreFundamentals) into our current session which we have installed in Step 12.
Browse for script file – installsc9.ps1 from the setup folder – D:\InstallSitecore9 (in my case)
Execute PS Script and Fingers Crossed.
Take a break – and you should be having your installation complete in next few minutes.
Verify SC 9 installation by opening up the instances.
This blog is my experience of taking me one step closer to Sitecore 9 installation. Its an extension of my previous post of setting up SOLR as Windows Service . After setting up SOLR as windows service I verified SOLR admin page with URL -http://localhost:8983/solr/
Purpose of this blog is to make it https => an extra s , that’s it!!! 🙂
In SC 9 SOLR by default needs to be setup in secure way. As this is for my local dev box I am going ahead with self signed certificates. Credit to Kam for providing us with a handy Power shell Script for generating self signed certificate and installing it .
Follow the below Steps for securing your SOLR Service in your local dev box.
Go to Kams webiste – and get the original PS script.(solrssl.ps1) . Many Thanks to Kam Figy for it.
Script makes use of Java keytool which is a certificate manager.
Figure out your keyttol.exe path from java directory in your PC. I have mine at C:\Program Files\Java\jre1.8.0_181\bin\keytool.exe
Open the script(solrssl.ps1) in an editor – and go to Line # 37 $keytool = (Get-Command 'keytool.exe').Source
Update Line #37 as below depending on your keytool.exe path figured out in previous step $keytool = (Get-Command 'C:\Program Files\Java\jre1.8.0_181\bin\keytool.exe').Source
Open Power shell as administrator and navigate to folder where you have kept PS file – solrssl.ps1 (from previous step)
Pass in location for the keystore file. .\solrssl.ps1 -KeystoreFile D:\SOLR\solr-6.6.2\server\etc\solr-ssl.keystore.jks
Execute PS and your keys are generated.
In case of Error- ” “File [.ps1] cannot be loaded because the execution of scripts is disabled on this system.” – Execute below line on Power shell window and re-run Step 8 Set-ExecutionPolicy -Scope CurrentUser Unrestricted
Verify if keystore files are created in location which we provided . In my case – i checked at path – D:\SOLR\solr-6.6.2\server\etc
Based on Next Steps from PS output of Step 9 – Open your solr.in.cmd file which should be inside bin folder of your SOLR installation folder. In my case its in – D:\SOLR\solr-6.6.2\bin\
Search for below 4 lines in solr.in.cmd file , un-comment all 4 lines and save the changes. set SOLR_SSL_KEY_STORE=etc/solr-ssl.keystore.jks
Restart your SOLR Service from Service Manager.
Check SOLR admin page – http URL- http://localhost:8983/solr/ – Yes this Page should not work now.
This blog will focus on setting up SOLR and running it as Windows Service using Non Sucking Service Manager tool. I have tried to list down each steps I did during my installation of SOLR 6.6.2 in my windows 10 dev machine.