EmailInfo - How to specify FTL template path under WEB-INF?

I have email.ftl under modules/portal/web/WEB-INF/templates/email/ (a subfolder I created). In my controller code, I have my EmailInfo declaration, and I want to specify the path to email.ftl.

Looking at this tutorial, I see the EmailInfo declaration is this:

EmailInfo emailInfo = new EmailInfo(
    Collections.singletonMap("newsItem", newsItem)

I notice the relative path leading to news_item.txt starts from “com/” which leads me to believe that the root of the path starts from the “src” folder of the module the controller is in (my controller is in app-portal, so in my case, portal/src). Since my template is under “web/” and not “src/”, I specified my path as so:

EmailInfo emailInfo = 
    new EmailInfo("", "Email Template", null, 
                  "../web/WEB-INF/templates/email/email.ftl", null, null);

However, it didn’t work, as an error was thrown:

java.lang.IllegalArgumentException: Could not find template by path: ../web/WEB-INF/templates/email/email.ftl

So my question is, how to specify this file path to go under a different subfolder, specifically “modules/portal/web”?

Thanks, Mingle

==X-posted to StackOverflow==


Unfortunately, you cannot store email templates in portal / web modules, since they are processed on a middleware. I recommend that you put them into core module src folder. In fact, “/” means CLASS-PATH root, not the folder.

Templates are loaded by Emailer using Resources interface which loads resources using the following rules:

Hi Yuriy,
Thanks! Putting it under core worked.