Uploaded image for project: 'Magnolia Standard Templating Kit (closed)'
  1. Magnolia Standard Templating Kit (closed)
  2. MGNLSTK-1517

TemplateCategoryUtil cannot be used in scheduler.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Won't Do
    • Neutral
    • None
    • None
    • None
    • None

    Description

      We run a scheduled job to calculate a sitemap.

      This happens since the update to M5:

      org.quartz.JobExecutionException: Cannot execute command {0}-{1}. [See nested exception: java.lang.IllegalStateException: Expected an instance of [info.magnolia.module.site.ExtendedAggregationState] for the [info.magnolia.cms.core.AggregationState]]
      	at info.magnolia.module.scheduler.CommandJob.execute(CommandJob.java:118)
      	at org.quartz.core.JobRunShell.run(JobRunShell.java:223)
      	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:549)
      Caused by: java.lang.IllegalStateException: Expected an instance of [info.magnolia.module.site.ExtendedAggregationState] for the [info.magnolia.cms.core.AggregationState]
      	at info.magnolia.module.site.provider.SiteProvider.get(SiteProvider.java:67)
      	at info.magnolia.module.site.i18n.SiteI18nContentSupport.getI18nContentSupport(SiteI18nContentSupport.java:69)
      	at info.magnolia.module.site.i18n.SiteI18nContentSupport.hasProperty(SiteI18nContentSupport.java:129)
      	at info.magnolia.module.site.i18n.SiteI18nContentSupport$$EnhancerByCGLIB$$8dfd2a7.hasProperty(<generated>)
      	at info.magnolia.jcr.wrapper.I18nNodeWrapper.hasProperty(I18nNodeWrapper.java:60)
      	at info.magnolia.jcr.wrapper.DelegateNodeWrapper.hasProperty(DelegateNodeWrapper.java:297)
      	at info.magnolia.jcr.util.NodeTypes$Renderable.getTemplate(NodeTypes.java:262)
      	at info.magnolia.module.templatingkit.templates.category.TemplateCategoryUtil.getTemplateSubCategory(TemplateCategoryUtil.java:108)
      	at nl.vpro.magnolia.module.vprotemplatingkit.util.VtkTemplateCategoryUtil.hasTemplateOfSubCategory(VtkTemplateCategoryUtil.java:82)
      	at nl.vpro.magnolia.module.vprotemplatingkit.util.VtkTemplateCategoryUtil.findParentsWithTemplateSubCategory(VtkTemplateCategoryUtil.java:69)
      	at nl.vpro.magnolia.module.vprotemplatingkit.util.VtkTemplateCategoryUtil.getNearestContentByTemplateCategorySubCategory(VtkTemplateCategoryUtil.java:43)
      	at nl.vpro.magnolia.module.vprotemplatingkit.util.VtkTemplateCategoryUtil.getProgramPlayer(VtkTemplateCategoryUtil.java:22)
      	at nl.vpro.magnolia.sitemap.PlayerAwareSiteMapCalculator.<init>(PlayerAwareSiteMapCalculator.java:55)
      	at nl.vpro.magnolia.sitemap.SiteMapUpdateCommand.execute(SiteMapUpdateCommand.java:49)
      	at info.magnolia.commands.MgnlCommand.executeSynchronized(MgnlCommand.java:80)
      	at info.magnolia.commands.MgnlCommand.execute(MgnlCommand.java:69)
      	at info.magnolia.module.scheduler.CommandJob.execute(CommandJob.java:110)
      
      

      The code to determin the template of a node needs an ExtendedAggregationState, which is not provided by the scheduler code

      That does:
      MgnlContext.setInstance(new SimpleContext(Components.getComponent(SystemContext.class)));

      It's btw a bit baffling why determining the template of a node needs I18n.

      Checklists

        Acceptance criteria

        Attachments

          Activity

            People

              Unassigned Unassigned
              mihxil Michiel Meeuwissen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: