velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Cornett" <adam.corn...@gmail.com>
Subject File Resource Loader
Date Sat, 05 May 2007 07:10:05 GMT
I am implementing Velocity in a website and everything is going
fine...except I can't get it to load templates from inside java code.  For
example, one class e-mails a registration confirmation to a user, I have a
template that sends them a pretty html e-mail, however when I try to load
the template, I get a
org.apache.velocity.exception.ResourceNotFoundException.  I have tried
several different fixes, from putting a copy of the template in every
reasonable directory, setting the file resource loader path... nothing
works.  Here is some of my code:

/* The function is called from a static method in a class via another
template located at /familyweekend/regapp/test_email.vm, with the template
file in the same directory. */
ExtendedProperties ep = new ExtendedProperties();
ep.setProperty("file.resource.loader.path", "/familyweekend/regapp,
/v_templates, .");
ep.setProperty("file.resource.loader.cache ", true);
ep.setProperty("file.resource.loader.modificationCheckInterval", 2);
ep.setProperty("resource.loader", "file");
VelocityEngine ve = new VelocityEngine();
ve.setExtendedProperties(ep);
Template tem== ve.getTemplate(EMail_Template);    /* EMail_Template is a
String defined else where, and yes, its the right name */

And it throws the error everytime at the last line.  I have no idea what I'm
doing wrong, and I've read the online documentation several times and it
doesn't seem to help.
-Adam Cornett

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message