My code as follow.
VelocityEngine ve = new VelocityEngine();
ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "class");
ve.setProperty("class.resource.loader.class", "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
ve.init();
Template tempalte = ve.getTemplate("templates/email/test.vm");
I am getting following error.
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'templates/email/test.vm' at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:452) at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:335) at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1102).....
"template" folder is in my src folder.
If I directly put the velocity template file into src folder and update as "Template tempalte = ve.getTemplate("test.vm");" it works.
I am using Mac OS, Java 1.8, Eclipse Neon.
Please help me to solve this.
Thanks and Regards, IsuruJ
Thanks for your time. This is an ANT project. Mistakenly I couldn't write script to copy templates folder to WEB-INF/classes folder. That was the issue. Both @user7294900 and @soorapadman are correct. The code works now.
Really sorry for the inconvenience.
Best Regards, IsuruJ