I was noticing that I hooked up that service using Spring, rather than in AppModule, but it shouldn't matter much.
private void init() { _logger.debug("init() starting"); if (_configuration == null) { _configuration = new Configuration(); String directory = null; directory = Messages .getString("SurveyActivityEmailRendererImpl.templateDirectory"); _configuration.setClassForTemplateLoading(getClass(), directory); if (_logger.isDebugEnabled()) _logger.debug("init(): set template directory to " + directory); } else { _logger.debug("init(): using existing Configuration"); } _configuration.setObjectWrapper(new DefaultObjectWrapper()); try { String file = Messages .getString("SurveyActivityEmailRendererImpl.templateHtml"); _template = _configuration.getTemplate(file); if (_logger.isDebugEnabled()) _logger.debug("init(): loaded template from " + file); } catch (IOException e) { throw new RuntimeException("init(): error on template load", e); } initialized = true; _logger.debug("init() completed initialization"); } My messages.properties file contained in the same directory as the service contains: SurveyActivityEmailRendererImpl.templateDirectory=/ SurveyActivityEmailRendererImpl.templateHtml=nightly-notification.ftl The template is in the root of the jar. The actual generation uses: try { Writer out = new StringWriter(); _template.process(data, out); out.flush(); htmlEmail = ((StringWriter) out).toString(); } catch (IOException e) { throw new RuntimeException(e); } catch (TemplateException e) { throw new RuntimeException(e); } return htmlEmail; On Tue, Jan 10, 2012 at 2:50 PM, Julien Martin <bal...@gmail.com> wrote: > Thanks a lot for your reply Jonathan, > Can you share some code sample (if you have it to hand) please? > Also where does this code go? > *configuration.setClassForTemplateLoading(Class clazz, String directory)* > Regards, > Julien. > > 2012/1/10 Jonathan Barker <jonathan.theit...@gmail.com> > >> The Freemarker project gave me similar problems. They have a >> Configuration object where you can do >> configuration.setClassForTemplateLoading(Class clazz, String >> directory). Does Velocity have the same option? If it does, I just >> used getClass() within my service to supply that Class parameter. >> >> On Tue, Jan 10, 2012 at 2:19 PM, Thiago H. de Paula Figueiredo >> <thiag...@gmail.com> wrote: >> > On Tue, 10 Jan 2012 16:09:07 -0200, Julien Martin <bal...@gmail.com> >> wrote: >> > >> >> Caused by: org.apache.velocity.exception.ResourceNotFoundException: >> Unable >> >> to find resource 'request-childminder-confirmation-mail-template_fr.htm' >> >> at >> >> >> org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474) >> > >> > >> > This is where the problem is. Tapestry itself doesn't change the >> classpath >> > at all, just the classloader for classes in the controlled packages, so >> this >> > isn't related to Tapestry. >> > >> > >> > -- >> > Thiago H. de Paula Figueiredo >> > Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, >> and >> > instructor >> > Owner, Ars Machina Tecnologia da Informação Ltda. >> > http://www.arsmachina.com.br >> > >> > --------------------------------------------------------------------- >> > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> > For additional commands, e-mail: users-h...@tapestry.apache.org >> > >> >> >> >> -- >> Jonathan Barker >> ITStrategic >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> -- Jonathan Barker ITStrategic --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org