0

I have following code:

public class EmailService {
        static {
        Velocity.setProperty("resource.loader", "class");
        Velocity.setProperty("class.resource.loader.class",
                "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader");
        Velocity.init();

        try {
            InputStream in = EmailService.class.getClassLoader()
                    .getResourceAsStream("support.properties");
            Properties prop = new Properties();
            prop.load(in);
            SUPPORT_EMAIL = prop.getProperty("mail", "");
        } catch (IOException e) {
            throw new RuntimeException("IOException while reading support.properties");
        }
    }

    ....


    private String getResultString(VelocityContext context, Template velocityTemplate) {
        StringWriter writer = new StringWriter();
        velocityTemplate.merge(context, writer);
        return writer.toString();
    }
}

when executes line:

velocityTemplate.merge(context, writer);

I see the following error:

Method threw 'org.apache.velocity.exception.ResourceNotFoundException' exception.
....
Unable to find resource 'footer.vm'

my template looks like this:

trololo
#include("footer.vm")

these two templates resides near on the filesystem. enter image description here How to fix this?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

1 Answers1

0

working after replacing path

#include("velocityTemplates/footer.vm")
gstackoverflow
  • 36,709
  • 117
  • 359
  • 710