On 5/5/07, Adam Cornett <[EMAIL PROTECTED]> wrote:
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.
are you using one of the servlets we provide (like the VelocityViewServlet)?
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 */
what properties are you using to configure Velocity elsewhere? the properties that work to load the template that calls this static method should work here too.
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.
have you tried using the WebappLoader from VelocityTools? it is more user-friendly in a webapp setting.
-Adam Cornett
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]