I have a hard time figuring out the reason for the following StructureMap error.
MyComputerName 2022-10-18 19:00:00,854 [119] ERROR EPiServer.DataAbstraction.ScheduledJob: Failed to create job instance for 'Generate search engine sitemaps' with jobId = '90c6cae4-9939-495c-ae61-40d9768e98b5'
EPiServer.ServiceLocation.ActivationException: Activation error occurred while trying to get instance of type SitemapXmlGeneratorFactory, key "" ---> StructureMap.StructureMapException: You cannot use the HttpContextLifecycle outside of a web request. Try the HybridLifecycle instead.
1.) new UrlLocalizationService(*Default of ICustomerNameLocalizationService*, *Default of ISiteDefinitionResolver*, *Default of IPageRouteHelper*, *Default of ICurrentCultureResolver*, *Default of IContentUrlResolver*, *Default of IUrlResolver*, *Default of IContentLanguageSettingsHandler*)
2.) CustomerName.EPiServer.Core.Services.UrlLocalizationService.UrlLocalizationService
3.) Instance of CustomerName.EPiServer.Core.Services.UrlLocalizationService.IUrlLocalizationService (CustomerName.EPiServer.Core.Services.UrlLocalizationService.UrlLocalizationService)
4.) new CustomerNameSitemapXmlGenerator(*Default of ISitemapRepository*, *Default of IContentRepository*, *Default of UrlResolver*, *Default of ISiteDefinitionRepository*, *Default of ILanguageBranchRepository*, *Default of IContentFilter*, *Default of IUrlLocalizationService*)
5.) CustomerName.EPiServer.Web.Helpers.Sitemap.CustomerNameSitemapXmlGenerator
6.) Instance of CustomerName.EPiServer.Web.Helpers.Sitemap.ICustomerNameSitemapXmlGenerator (CustomerName.EPiServer.Web.Helpers.Sitemap.CustomerNameSitemapXmlGenerator)
7.) All registered children for IEnumerable<ICustomerNameSitemapXmlGenerator>
8.) Instance of IEnumerable<ICustomerNameSitemapXmlGenerator>
9.) new CustomerNameSitemapXmlGeneratorFactory(*Default of IEnumerable<ICustomerNameSitemapXmlGenerator>*)
10.) CustomerName.EPiServer.Web.Helpers.Sitemap.CustomerNameSitemapXmlGeneratorFactory
11.) Instance of Geta.SEO.Sitemaps.Utils.SitemapXmlGeneratorFactory (CustomerName.EPiServer.Web.Helpers.Sitemap.CustomerNameSitemapXmlGeneratorFactory)
12.) Container.GetInstance(Geta.SEO.Sitemaps.Utils.SitemapXmlGeneratorFactory)
bei lambda_method(Closure , IBuildSession , IContext )
bei StructureMap.Building.BuildPlan.Build(IBuildSession session, IContext context)
bei StructureMap.Pipeline.LazyLifecycleObject`1.CreateValue()
bei StructureMap.SessionCache.GetObject(Type pluginType, Instance instance, ILifecycle lifecycle)
bei StructureMap.SessionCache.GetDefault(Type pluginType, IPipelineGraph pipelineGraph)
bei StructureMap.Container.GetInstance(Type pluginType)
bei EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
--- Ende der internen Ausnahmestapelüberwachung ---
bei EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance(Type serviceType, String key)
bei EPiServer.ServiceLocation.ServiceLocatorImplBase.GetInstance[TService]()
bei Geta.SEO.Sitemaps.SitemapCreateJob..ctor()
Some background:
We're using Episerver/Optimizely 11 and the geta-sitemap plugin to generate the sitemaps. I needed to provide a custom SitemapXmlGenerator to provide a custom logic for the x-default url. Everything is working if i trigger sitemaps from CMS (so from web via Admin/ Generate search engine sitemaps). If the generation is triggered from geta scheduled job, StructureMap cannot create instances of the used types.
I can provide more context(classes, DependencyInjectionRegistry, InitializationModule) if necessary. What can be the reason of this error, how to tackle it down?