How to read a Velocity template from a plugin?

I'm trying, without much success, to load a velocity template that is packaged in my plugin jar. Here is the code I am using:

VelocityEngine ve = new VelocityEngine();
Properties p = new Properties();

p.put("resource.loader", "class");
p.put("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");

Template t = ve.getTemplate("/fileTemplates/kit.xml.vm");

I get a ResourceNotFoundExcpeption with this code.

I have verified that my plugin jar has /fileTemplates/kit.xml.vm in it, so clearly there is something wrong with how I am setting up my velocity engine.

If this question has been answered in another post, please point me there. Otherwise, any guidance would be greatly appreciated.


Please sign in to leave a comment.