Error getting a templated email containing @extends to send.

Essentially, when I make a base template for emails and I try to extend it using @extends..., I get the following error when Nuxeo should send email :

10:56:25,864 ERROR [runtime] 

on line 1, column 1 in modif extends not found.
The problematic instruction:
----------
==> user-directive extends [on line 1, column 1 in modif]
----------

Java backtrace for programmers:
----------
freemarker.core.InvalidReferenceException: on line 1, column 1 in modif extends not found.
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:134)
    at freemarker.core.Environment.visit(Environment.java:208)
    at freemarker.core.Environment.process(Environment.java:188)
    at freemarker.template.Template.process(Template.java:232)
    at org.nuxeo.ecm.platform.rendering.template.FreemarkerRenderingEngine.process(FreemarkerRenderingEngine.java:62)
    at org.nuxeo.ecm.platform.rendering.impl.RenderingServiceImpl.process(RenderingServiceImpl.java:91)
    at org.nuxeo.ecm.platform.ec.notification.email.EmailHelper.sendmail(EmailHelper.java:150)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.sendNotification(NotificationEventListener.java:303)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.sendNotificationSignalForUser(NotificationEventListener.java:226)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.handleNotifications(NotificationEventListener.java:128)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.handleEvent(NotificationEventListener.java:92)
    at org.nuxeo.ecm.core.event.impl.AsyncEventExecutor$Job.run(AsyncEventExecutor.java:159)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
10:56:25,864 ERROR [NotificationEventListener] An error occurred while trying to send user notification
org.nuxeo.ecm.core.api.ClientException: Failed to send notification email 
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.sendNotification(NotificationEventListener.java:308)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.sendNotificationSignalForUser(NotificationEventListener.java:226)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.handleNotifications(NotificationEventListener.java:128)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.handleEvent(NotificationEventListener.java:92)
    at org.nuxeo.ecm.core.event.impl.AsyncEventExecutor$Job.run(AsyncEventExecutor.java:159)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:679)
Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: org.nuxeo.ecm.platform.rendering.RenderingException. message: Freemarker processing failed
    at org.nuxeo.ecm.platform.rendering.template.FreemarkerRenderingEngine.process(FreemarkerRenderingEngine.java:68)
    at org.nuxeo.ecm.platform.rendering.impl.RenderingServiceImpl.process(RenderingServiceImpl.java:91)
    at org.nuxeo.ecm.platform.ec.notification.email.EmailHelper.sendmail(EmailHelper.java:150)
    at org.nuxeo.ecm.platform.ec.notification.NotificationEventListener.sendNotification(NotificationEventListener.java:303)
    ... 7 more
Caused by: org.nuxeo.ecm.core.api.WrappedException: Exception: freemarker.core.InvalidReferenceException. message: on line 1, column 1 in modif extends not found.
    at freemarker.core.UnifiedCall.accept(UnifiedCall.java:134)
    at freemarker.core.Environment.visit(Environment.java:208)
    at freemarker.core.Environment.process(Environment.java:188)
    at freemarker.template.Template.process(Template.java:232)
    at org.nuxeo.ecm.platform.rendering.template.FreemarkerRenderingEngine.process(FreemarkerRenderingEngine.java:62)
    ... 10 more

I've read that this seems to be that it can't find the file I'm referring to, which is in the same directory.

I then tried to deploy it to nxserver/nuxeo.war/skin/, which also fails with the same error.

Is it really a file location issue?

To me it sounds like a parser error, as if it didn't know what to do with the @extends directive.

0 votes

0 answers

852 views

ANSWER

How does your mail template look like ?
05/24/2012

baseNotificationTemplate.ftl :

<html>
<body>
<p>
<@block name="notif_text">
Une notification a été envoyée pour le document <b>${htmlEscape(docTitle)}</b>.
</@block>
</p>
</body>
</html>

modif.ftl :

<@extends src="baseNotificationTemplate.ftl">
        <@block name="notif_text">
        Le document <b>${htmlEscape(docTitle)}</b> a été modifié dans Nuxeo.
        </@block>
</@extends>

This is obviously a simplified version, but this example still fails. In this case, the reason for the templating is that we want sane defaults for the blocks. But it doesn't even get to a block, it just fails at the first character on the first line…

05/24/2012

I guess it's because the <@extends> directive is not available in the ftl rendering engine of the notification service. It will only work in a WebEngine ftl rendering engine. We obviously need to refactor the old notification service…
05/24/2012