Quantcast
Viewing latest article 8
Browse Latest Browse All 5648

PageRenderLinkSource failing in service when called by cron scheduler - Unable to delegate method invocation to property

I'm using T5 beta-25 and I have the following code and I'm noticing
when the scheduler fires off my service, my PageRenderLinkSource does
not work. If I manually fire it off through the admin with an
actionlink, it works without issue.

AppModule.class

@Startup
public static void initApplication(SchedulerService scheduler) {
scheduler.init();

SchedulerService.class

executor.addJob(new CronSchedule("0 09 4 * * ?"),
"Cleanup Listings", () -> {
try {
System.out.println("sitemap");
sitemap.buildSitemap();
} catch (JAXBException | IOException ex) {

Logger.getLogger(SchedulerServiceImpl.class.getName()).log(Level.SEVERE,
null, ex);

});

SitemapService.class

private final PageRenderLinkSource linkSource;

public SitemapImpl(PageRenderLinkSource linkSource) {
this.linkSource = linkSource;

private void setSitemapXML(Class<?> clazz, UrlSet urlset, Object[] object) {
SitemapXML siteMapXML = new SitemapXML();
System.out.println("link");

Link link = linkSource.createPageRenderLinkWithContext(clazz, object);
System.out.println(link.toAbsoluteURI());

link.setSecurity(LinkSecurity.SECURE);
siteMapXML.setChangefreq(ChangeFreq.ALWAYS.toString());
siteMapXML.setLoc(link.toAbsoluteURI());
siteMapXML.setPriority(0.5);
urlset.getSitemaps().add(siteMapXML);

I'm seeing the following exception
java.lang.NullPointerException: Unable to delegate method invocation
to property 'request' of <Proxy for
RequestGlobals(org.apache.tapestry5.services.RequestGlobals)>, because
the property is null.

Any idea why this isn't working?

Viewing latest article 8
Browse Latest Browse All 5648

Trending Articles