I already found a workaround for this problem by calling
Content.getNodeData("title") instead of Content.getTitle().
Kind regards,
Ronald
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ronald Ten Berge
Sent: dinsdag 29 maart 2011 13:57
To: Magnolia User-List
Subject: [magnolia-user] AbstractI18nContentSupport.getLocale() exception while
running a command
Hi,
I have implemented an exporter that is being scheduled using the scheduler
module. Magnolia throws a IllegalStateException while running the export
command, because a command uses a SimpleContext and not a WebContext.
Is there a workaround available for this problem, or do I have to create a
servlet that runs the exporter?
Relevant code
--
[AbstractI18nContentSupport:85-92]
public Locale getLocale() {
final Locale locale = MgnlContext.getAggregationState().getLocale();
if (locale == null) {
return fallbackLocale;
} else {
return locale;
}
}
[MgnlContext:212-223]
/**
* Returns the AggregationState if we're in a WebContext, throws an
* IllegalStateException otherwise.
*/
public static AggregationState getAggregationState() {
final WebContext ctx = getWebContextOrNull();
if (ctx != null) {
return ctx.getAggregationState();
} else {
throw new IllegalStateException("Can only get the aggregation
state within a WebContext.");
}
}
--
Exception
--
Caused by: java.lang.IllegalStateException: Can only get the aggregation state
within a WebContext.
at
info.magnolia.context.MgnlContext.getAggregationState(MgnlContext.java:221)
at
info.magnolia.cms.i18n.AbstractI18nContentSupport.getLocale(AbstractI18nContentSupport.java:86)
at
info.magnolia.cms.i18n.AbstractI18nContentSupport.getNodeData(AbstractI18nContentSupport.java:222)
at
info.magnolia.cms.i18n.DefaultI18nContentSupport$$EnhancerByCGLIB$$dc95c9c4.getNodeData(<generated>)
at
info.magnolia.cms.core.AbstractContent.getTitle(AbstractContent.java:336)
at
trimm.nxp.wcm.exporter.RelatedApplicationsExporter._handleRelatedApplications(RelatedApplicationsExporter.java:101)
at
trimm.nxp.wcm.exporter.RelatedApplicationsExporter.exportPath(RelatedApplicationsExporter.java:315)
at
trimm.nxp.wcm.commands.ExecuteExporterCommand.execute(ExecuteExporterCommand.java:63)
at
info.magnolia.commands.MgnlCommand.executePooledOrSynchronized(MgnlCommand.java:170)
... 4 more
--
Kind regards,
Ronald
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------