7

The CD version of Sitecore 9 was installed on our CD server. The error below is typically seen with a SwitchMasterToWeb.config file issue in previous versions:

Post condition failed 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:

System.InvalidOperationException: Post condition failed

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[InvalidOperationException: Post condition failed]
Sitecore.Diagnostics.Assert.ResultNotNull(T result, String message) +85 Sitecore.Configuration.DefaultFactory.GetDatabase(String name) +86 Sitecore.Configuration.DefaultFactory.GetDatabases() +121 Sitecore.Data.Managers.DefaultItemManager.Initialize() +110 (Object , Object[] ) +120 Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +479 (Object , Object[] ) +71
Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args) +479
Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain) +22
Sitecore.Nexus.Web.HttpModule.Application_Start() +161
Sitecore.Nexus.Web.HttpModule.Init(HttpApplication app) +767
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +583
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +169
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +396
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +333

[HttpException (0x80004005): Post condition failed]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +525
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +124 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +700

In this case, with Sitecore 9 we are getting this error with the CD version. Configuration role for CM is set to "ContentManagement" with CD being "ContentDelivery".

To my understanding, this is all you need to do to have your CD instance all setup since there is no longer a SwitchMasterToWeb.config in Sitecore 9.

Am I missing something? Any ideas or anyone seen this before on a CD instance with Sitecore 9?

  • Did you get chance to have a look at this blog post from jammykam on configuring roles on Sitecore 9 ? jammykam.wordpress.com/2017/10/17/rules-based-configuration – Amitabh Vyas Jan 16 '18 at 20:34
  • I did. Looked through and that's how I made my change to "ContentManagement" and "ContentDelivery" for the roles from "Standalone". Again, I believe that is all that is needed, but no-go for now. – Toby Gutierrez Jan 16 '18 at 21:40
  • @TobyGutierrez if this question is now answered, can you mark the answer please? – Richard Seal May 10 '18 at 14:30
  • I want to also note that this is a very ambiguous error. This can happen if the configuration of the core db is missing in the Sitecore.config. This happened to us when our transforms went haywire. it was not an easy thing to track down. – Chris Bartlett Jun 26 '18 at 22:41
1

In my case, I had the same error when I delivered Unicorn configs to CD server. I removed all Unicorn configs from CD and added Unicorn folder with configs to my pubxml:

<Target Name="ConfigFiles" BeforeTargets="ExcludeFilesFromPackage">
    <ItemGroup>
      <ExcludeFromPackageFolders Include="App_Config\Include\Unicorn">
        <FromTarget>Project</FromTarget>
      </ExcludeFromPackageFolders>
      <ExcludeFromPackageFiles Include="App_Config\Include\*.disabled">
      </ExcludeFromPackageFiles>
      <ExcludeFromPackageFiles Include="App_Config\Include\*.example">
      </ExcludeFromPackageFiles>
      <ExcludeFromPackageFiles Include="App_Config\Include\*.exclude">
      </ExcludeFromPackageFiles>
    </ItemGroup>
  </Target>
0

I solved this issue by redeploying my latest code with "ContentManagement" in place for the CM server configuration role and "ContentDelivery" in place for the CD server configuration role. When the deploy finished as successful it was only then that everything started working. Apparently, simply modifying in the Web.configs, via patch file of course, and doing a recycle did not do the trick for me. Happy coding!

  • Well, you can't patch the Web.config file and thereby the app settings, so that might have been why :) – Søren Kruse Jan 17 '18 at 7:46
  • My apologies. I meant a .config transform via Slow Cheetah. – Toby Gutierrez Jan 17 '18 at 12:44
0

In my case, I solved it by removing the Unicorn.DataProvider.config file from the CD environment. This config file contains the following section:

<sitecore>
  <databases>
      <database id="master">

... which causes Sitecore to look for a master database, which in turn causes the exception.

  • 1
    As stated in Unicorn.DataProvider.config; This file should be removed in ANY deployed instance (CE or CD) that does not act as a source for serialized item updates. – Mark Cassidy Nov 20 '18 at 13:56
0

In my case I fixed the issue on our CD server by running the following Script in powershell after having running unicorn sync.

Remove-Item -Path "$WebsiteDir\$WebsiteDir\App_Config\Include\Unicorn" -Force -Recurse -Verbose

Apparently leaving it on the CMS server works, but not the CD.

0

Obviously, the cause of this error is diverse.

The error message appears when configuration define a database that is not configured or available in the environment.

I had this issue with Sitecore module UrlRewrite. Please make sure that:

Hi.UrlRewrite.Prefetch.Master.config

is disabled in CD enviroment.

New contributor
mkubasch is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.