Discussion:
[FreeMarker-user] Template not found in Unix Crontab
Daniel Dekany
11 years ago
Permalink
The problem is that cfg doesn't load templates from an absolute file
paths. It loads them from a virtual file system that you should
specify to cfg, but you haven't, so it uses the default one that you
just shouldn't ever use (backward compatibility burden...). Since you
want to load templates from plain files (as opposed to from classpath,
etc), you should add:

cfg.setDirectreyForTemplateLoader(new File(absolutePath))

The path passed to getTemplate will *always* be interpreted relatively
to this directory.

Note that if you don't need template caching and templates loading
each other, you can also just use `new Template(name, reader, cfg)`
instead of cfg.getTemplate.
--
Thanks,
Daniel Dekany
...
Loading...