I’m trying to run velocity email sender program in Java 1.6 but its not finding recourse…
VelocityContext context = new VelocityContext();
context.put("name", "mike");
// Initialize the engine
try {
VelocityEngine ve = new VelocityEngine();
templateName = "myfile_en.vm";
// Load the template
Template template = ve.getTemplate(templateName, "UTF-8");
// Render the template into a writer
StringWriter writer = new StringWriter();
template.merge(context, writer);
Cam any one help me out why I’m not able to load myfile_en.vm??? I tried giving full absolute path as well but still same error: ResourceNotFound
I’m running it directly from eclipse. Any help is much appreciated.
Thanks!
It really depends on where your template file is. Velocity always has an issue with it. To get around it you need to ensure that the templates are locatable on your classpath. Either in a jar or on the filesystem directly. Once its on your classpath, init Velocity like this…
This tells Velocity to look for template files in the classpath.