严重的 Sitecore MVC/Glassmapper 问题
Serious Sitecore MVC/Glassmapper issue
我们有一个客户的 Sitecore 站点抛出一个似乎与 MVC and/or Glassmapper 有关的错误。它发生在内容交付服务器上,在负载测试期间处于一定负载下(不是很大)。它似乎发生在站点首次编译时。在此事件之前,我们关闭了一个 sitecore ("HostingEnvironment initiated shutdown"),当它重新启动时,在主视图中命中的第一行代码会引发错误。如果我删除那一行,然后是错误之后的那一行,等等,一直到页面下方。就好像没有代码可以运行,就像什么东西在重新启动时就变坏了一样。如果我重置 IIS,问题就会消失。我们所有的代码都编译在 DLL 中,当然,Razor 视图除外。
我知道这是一个很大的问题,但如果有人遇到过这样的问题或有任何想法去哪里寻找,我们将不胜感激!
这是堆栈跟踪:
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.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.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at Sitecore.Mvc.Controllers.SitecoreActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.<>c__DisplayClass22.<BeginExecuteCore>b__1e()
at System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.InvalidOperationException
Message: Error while rendering view: '/Views/Chrome.cshtml' (model: 'Castle.Proxies.IPageBaseProxy, DynamicProxyGenAssembly2').
Source: Sitecore.Mvc
at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
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.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
Nested Exception
Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: System.Core
at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
at System.Collections.Generic.HashSet`1.Add(T item)
at Glass.Mapper.Sc.DataMappers.SitecoreFieldStringMapper.GetField(Field field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
at Glass.Mapper.Sc.DataMappers.AbstractSitecoreFieldMapper.MapToProperty(AbstractDataMappingContext mappingContext)
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.LoadValues()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.get_Values()
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.IPageBaseProxy.get_TemplateId()
at ASP._Page_Views_Chrome_cshtml.Execute() in d:\Webroot\Sitecore\Website\Views\Chrome.cshtml:line 11
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
错误代码如下:
Line 9: var bodyClass = "";
Line 10:
Line 11: if (Model.TemplateId == GlobalId.ArticlePageTemplate.Guid)
Line 12: {
Line 13: bodyClass = "pagetype-article";
第11行是错误发生的地方。不知道是模型还是我们对静态 ID 的调用。请记住,这是调用我们的编译代码 (DLL) 的第一行代码。如果我删除它,下一个类似的将出错。我已经对页面上的每一行代码都进行了测试。
获得了一些额外信息:
在这种情况下,服务器是由 IT 人员重新启动的,因此关闭是正常的并且是有计划的。所以,我认为负载测试是一个转移注意力的问题。尽管我们已经在负载测试期间看到错误发生,但看起来这种情况可能会在应用启动后的第一个请求中随机发生。
这是 Glass Mapper 的一个已知问题并已修复:
https://github.com/mikeedwards83/Glass.Mapper/issues/100
你应该更新到最新的 Glass Mapper 版本来摆脱这个问题。
我们有一个客户的 Sitecore 站点抛出一个似乎与 MVC and/or Glassmapper 有关的错误。它发生在内容交付服务器上,在负载测试期间处于一定负载下(不是很大)。它似乎发生在站点首次编译时。在此事件之前,我们关闭了一个 sitecore ("HostingEnvironment initiated shutdown"),当它重新启动时,在主视图中命中的第一行代码会引发错误。如果我删除那一行,然后是错误之后的那一行,等等,一直到页面下方。就好像没有代码可以运行,就像什么东西在重新启动时就变坏了一样。如果我重置 IIS,问题就会消失。我们所有的代码都编译在 DLL 中,当然,Razor 视图除外。
我知道这是一个很大的问题,但如果有人遇到过这样的问题或有任何想法去哪里寻找,我们将不胜感激!
这是堆栈跟踪:
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.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.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at Sitecore.Mvc.Controllers.SitecoreActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
at System.Web.Mvc.Controller.<>c__DisplayClass22.<BeginExecuteCore>b__1e()
at System.Web.Mvc.Async.AsyncResultWrapper.<.cctor>b__0(IAsyncResult asyncResult, Action action)
at System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at System.Web.Mvc.MvcHandler.<BeginProcessRequest>b__5(IAsyncResult asyncResult, ProcessRequestState innerState)
at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult)
at Sitecore.Mvc.Routing.RouteHttpHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.InvalidOperationException
Message: Error while rendering view: '/Views/Chrome.cshtml' (model: 'Castle.Proxies.IPageBaseProxy, DynamicProxyGenAssembly2').
Source: Sitecore.Mvc
at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Render(Renderer renderer, TextWriter writer, RenderRenderingArgs args)
at Sitecore.Mvc.Pipelines.Response.RenderRendering.ExecuteRenderer.Process(RenderRenderingArgs args)
at (Object , Object[] )
at Sitecore.Pipelines.CorePipeline.Run(PipelineArgs args)
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.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)
Nested Exception
Exception: System.IndexOutOfRangeException
Message: Index was outside the bounds of the array.
Source: System.Core
at System.Collections.Generic.HashSet`1.AddIfNotPresent(T value)
at System.Collections.Generic.HashSet`1.Add(T item)
at Glass.Mapper.Sc.DataMappers.SitecoreFieldStringMapper.GetField(Field field, SitecoreFieldConfiguration config, SitecoreDataMappingContext context)
at Glass.Mapper.Sc.DataMappers.AbstractSitecoreFieldMapper.MapToProperty(AbstractDataMappingContext mappingContext)
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.LoadValues()
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.get_Values()
at Glass.Mapper.Pipelines.ObjectConstruction.Tasks.CreateInterface.InterfacePropertyInterceptor.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.IPageBaseProxy.get_TemplateId()
at ASP._Page_Views_Chrome_cshtml.Execute() in d:\Webroot\Sitecore\Website\Views\Chrome.cshtml:line 11
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.Html.PartialExtensions.Partial(HtmlHelper htmlHelper, String partialViewName, Object model, ViewDataDictionary viewData)
at Sitecore.Mvc.Presentation.ViewRenderer.Render(TextWriter writer)
错误代码如下:
Line 9: var bodyClass = "";
Line 10:
Line 11: if (Model.TemplateId == GlobalId.ArticlePageTemplate.Guid)
Line 12: {
Line 13: bodyClass = "pagetype-article";
第11行是错误发生的地方。不知道是模型还是我们对静态 ID 的调用。请记住,这是调用我们的编译代码 (DLL) 的第一行代码。如果我删除它,下一个类似的将出错。我已经对页面上的每一行代码都进行了测试。
获得了一些额外信息: 在这种情况下,服务器是由 IT 人员重新启动的,因此关闭是正常的并且是有计划的。所以,我认为负载测试是一个转移注意力的问题。尽管我们已经在负载测试期间看到错误发生,但看起来这种情况可能会在应用启动后的第一个请求中随机发生。
这是 Glass Mapper 的一个已知问题并已修复:
https://github.com/mikeedwards83/Glass.Mapper/issues/100
你应该更新到最新的 Glass Mapper 版本来摆脱这个问题。