[MGNLSTK-1517] TemplateCategoryUtil cannot be used in scheduler. Created: 25/Nov/15  Updated: 02/Jul/18  Resolved: 02/Jul/18

Status: Closed
Project: Magnolia Standard Templating Kit (closed)
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Michiel Meeuwissen Assignee: Unassigned
Resolution: Won't Do Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Acceptance criteria:
Empty
Date of First Response:

 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.



 Comments   
Comment by Michiel Meeuwissen [ 25/Nov/15 ]

It seems that I can work around by completely unwrapping my nodes first:

 Node current = pageNode;
        while (current instanceof DelegateNodeWrapper) {
            current = ((DelegateNodeWrapper) current).getWrappedNode();
        }

I don't know what wrapped my nodes in the first place.

Comment by Jan Haderka [ 02/Jul/18 ]

STK have been deprecated in September 2017. As part of this project nearing end-of-life, we are not planning to fix any of the existing issues except for the critical security issues. For more details, please consult documentation.

Generated at Mon Feb 12 07:37:19 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.