Hi,

I'm trying to use freemarker templates according to the following
instructions:
http://chenillekit.codehaus.org/chenillekit-template/howto_freemarkerservice.html

My code in AppModule is the same as specified above.

In my Java code I'm trying to send mail with the use of a template file:

OutputStream emailBodyStream = new ByteArrayOutputStream();
templateService.mergeDataWithResource(new
URIResource("./templates/test.ftl"), emailBodyStream, parameterMap);
mailService.sendHtmlMail(mmh, emailBodyStream.toString());


The template file is not found - I get exceptions no matter how I set the
URIResource path to the template file:

- If the path is "./templates/test.ftl", there's a
"java.lang.IllegalArgumentException: URI is not absolute" exception in
URIResource.exists() method when calling uri.toURL().
Why does this error occur? (the instructions specify relative path to the
file as a parameter to the URIResource).

- If the path is an absolute filepath, i.e.
"file:/home/lidija/workspace/.../templates/test.ftl", there's a
"java.lang.RuntimeException: Template file:/home/lidija/workspace/... not
found". The file exists though and has read / write / execute permissions
on it.
(I'm just trying to understand, of course the path shouldn't be set like
this.)

- If the path is absolute filepath to the file, without the "file:" String,
the eror is again "java.lang.IllegalArgumentException: URI is not absolute"


My questions are:
- should I specifically set the path to the "templates" folder at
configuration time?
- how to specify the template filename parameter to URIResource?

Any suggestions welcome.

Kind regards,
Lidija

Reply via email to