Include not working on freemarker template on email connector

I’m trying to send an email with a template file included as resource.
The main file is detected, but seems it’s not finding the include file

<#include “footer.ftl”>

I’m not sure why is not finding it because it’s there.
Any solution for this?

25-Jan-2017 16:42:57.732 SEVERE [pool-2-thread-1] org.camunda.commons.logging.BaseLogger.logError ENGINE-16006 BPMN Stack Trace:
25-Jan-2017 16:42:57.732 SEVERE [pool-2-thread-1] org.camunda.commons.logging.BaseLogger.logError ENGINE-16004 Exception while closing command context: Unable to evaluate script: freemarker.core._MiscTemplateException: Error reading included file “./footer.ftl”:

I think we need a way for freemarker configuration to configure the template location for the templates so I can use include.

If we could have a configuration that I can setup and point to the proper folder with the templates.

Hi @lcrodriguez where is footer.ftl located in your project? could you post a tree?

Sure. I have a project with my processes which I generate as a war and drop into tomcat webapps.

src/main/resources/templates/premium-request/no-records.ftl
src/main/resources/templates/premium-request/footer.ftl

And I’m using it like this in a connector:

    <camunda:inputParameter name="html">
      <camunda:script scriptFormat="freemarker" resource="templates/premium-request/no-records.ftl" />
    </camunda:inputParameter>

I guess it’s not looking for the templates in the classpath folder because it does not know about them and I could not find a way to configure them.

Hi @lcrodriguez,

does it work if you adjust your
<#include "footer.ftl">

to
<#include "templates/premium-request/footer.ftl">

Cheers,
Askar

Yes. I tried that and did not work either.

@lcrodriguez,

with same stack trace or different?

Cheers,
Askar

Yes, unfortunately. I will try again just in case and post results again.

Hi @lcrodriguez,

that means that freemarker template is not on the same classpath, to verify that could you try to put your template directly into engine webapp’s classes folder?

Cheers,
Askar

I’m using Tomcat. Where should that be located?

@lcrodriguez,

that’s a shared engine I assume, so probably
server/apache-tomcat-8.0.24/lib

Cheers,
Askar

I see what you mean. That would be a workaround to symlink my folder here… not ideal but should work.
We should be able to configure the locations for freemarker templates somehow in the future, this is very useful for customizations.

Hi

This thread from the old forum may be of interest.

In addition, it looks like this (CAM-3688) ticket may be related .

regards

Rob

Hi @Webcyberrob, @lcrodriguez,

yes, https://app.camunda.com/jira/browse/CAM-3688 looks like exactly what you need. You can vote on that ticket, but I cannot do any promises on when it will be implemented. If you want you can always prepare pull request with implementation, they are more then welcome.

Cheers,
Askar.

Yes, thanks.
I could do a PR reading from the camunda.cfg.xml the configuration paths either file or classpaths so it’s more generic.
How could I read the configuration file?

I’ve ended up recompiling the Javascript Engine to read the templates from the classpath://templates/ as default to overcome the problem. I’m not sure how to get or pass a camunda.cfg.xml into it.