I'm working on a SC 10.2 JSS site. On previous MVC projects I was always able to enter Experience Editor / Preview mode while building branch templates for pages. That is, the items such as /sitecore/templates/Branches/Project/Main/MyPage/$name
.
However, I always run into this error:
30960 09:48:43 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: An unhandled exception occurred.
Source: Sitecore.Mvc
at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.ShowErrorMessage(ExceptionContext exceptionContext, ExceptionArgs args)
at Sitecore.Mvc.Pipelines.MvcEvents.Exception.ShowAspNetErrorMessage.Process(ExceptionArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Filters.PipelineBasedRequestFilter.OnException(ExceptionContext exceptionContext)
at System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList`1 filters, Exception exception)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult)
at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: Sitecore.JavaScriptServices.ViewEngine.RenderingEngine.ApplicationNotFoundException
Message: A Sitecore.JavaScriptServices application was not found for the path /sitecore/templates/Branches/Project/Main/MyPage/$name. You should ensure that:
* You have applied a Sitecore configuration patch for the application (see App_Config\Sitecore\JavaScriptServices\Sitecore.JavaScriptServices.ExampleApp.config.example)
* The path represents a Route
* The Route item is a descendant of an App item
Source: Sitecore.JavaScriptServices.ViewEngine
at Sitecore.JavaScriptServices.ViewEngine.Presentation.Pipelines.MvcGetRenderer.GetJsLayoutRenderer.ResolveAppConfiguration(Item contextItem)
at Sitecore.JavaScriptServices.ViewEngine.Presentation.Pipelines.MvcGetRenderer.GetJsLayoutRenderer.GetRenderer(GetRendererArgs args)
at Sitecore.JavaScriptServices.ViewEngine.Presentation.Pipelines.MvcGetRenderer.GetJssRenderer.Process(GetRendererArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs,TResult](String pipelineName, TArgs args, Func`2 resultGetter)
at Sitecore.Mvc.Presentation.Rendering.GetRenderer()
at Sitecore.Mvc.Presentation.Rendering.get_Renderer()
at Sitecore.Mvc.Presentation.Rendering.ToString()
at Sitecore.Mvc.Pipelines.Response.RenderRendering.InitializeProfiling.StartProfiling(RenderRenderingArgs args)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.InitializeProfiling.Process(RenderRenderingArgs args)
at (Object , Object )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain, Boolean failIfNotExists)
at Sitecore.Pipelines.DefaultCorePipelineManager.Run(String pipelineName, PipelineArgs args, String pipelineDomain)
at Sitecore.Mvc.Pipelines.PipelineService.RunPipeline[TArgs](String pipelineName, TArgs args)
at Sitecore.Mvc.Presentation.RenderingView.Render(ViewContext viewContext, TextWriter writer)
at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult)
at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult)
at System.Web.Mvc.Async.AsyncControllerActionInvoker.<>c__DisplayClass3_1.<BeginInvokeAction>b__5(IAsyncResult asyncResult)
Aside from this error, I am not finding any helpful information in the JSS/Sitecore logs. When I run in debug mode, I don't see any exceptions getting thrown in my custom code. That makes sense because the error is happening at a much higher level. Everything else is working as expected and I can enter preview/edit mode on regular content items.
Looking at what the error suggests:
- The item in question does inherit from the Route template.
- The URL for the preview/edit view contains
sc_site=main
; that ishttps://mysite.sc/?sc_mode=edit&sc_itemid=%7bxxxxxxxxx%7d&sc_version=1&sc_lang=en&sc_site=main
- My config is defined as follows:
<app name="main"
sitecorePath="/sitecore/content/Sites/Main"
graphQLEndpoint="/api/main"
serverSideRenderingEngine="http"
serverSideRenderingEngineEditOnly="false"
serverSideRenderingEngineEndpointUrl="http://localhost:3000/api/editing/render"
serverSideRenderingEngineApplicationUrl="http://localhost:3000"
useLanguageSpecificLayout="true"
defaultWorkflow=""
protectDeveloperItems="false"
deploymentSecret=""
inherits="defaults"
dictionaryDomain="{6336E54C-9D3D-462B-A6F3-CF58C6B16AED}"
patch:source="Sites.config"
/>
It makes sense that an application was not found for the branch template item when it does not exist under sitecorePath="/sitecore/content/Sites/Main"
, but it isn't clear how I can make this work.
The only other posts that cite this error are below:
- https://www.linkedin.com/pulse/jss-layout-services-troubleshooting-arvind-gehlot
- https://hishaamn.wordpress.com/2021/06/18/sitecore-jss-sxa-application-not-found/
One of these mentioned this:
The Root start item (in your site config patch file) should be a descendant of an App item
Clearly, branch templates are not a descendant of an App item, but could we somehow make them be a descendant of an App item? Or is there another way to get this working?