1

I'm currently using Spark and trying to use templates via Velocity based on the documentation.

I'm however having some errors, could anyone provide guidance on how I can successfully load the templates?

Aug 22, 2017 2:26:43 PM org.apache.velocity.runtime.log.JdkLogChute log
SEVERE: ResourceManager : unable to find resource 'www/templates/template.html' in any resource loader.
[qtp1951434327-14] ERROR spark.http.matching.GeneralError - 
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'www/templates/template.html'
public class Minimal {
        
    public static void main(String[] args) {
        get("test", (req, res) -> {
            Map<String, Object> model = new HashMap<>();
            return render(model, "www/templates/template.html");
        });
    }
        
    public static String render(Map<String, Object> model, String path) {
        return new VelocityTemplateEngine().render(new ModelAndView(model, path));
    }
}

I've read and tried solutions on many Stack Overflow questions, however none of them seem to be helping in my case.

Some solutions have included setting properties, or having a particular project structure etc. Though it appears none of these have solved the issue, and leads to the same exception.

Seth Falco
  • 313
  • 6
  • 22

1 Answers1

1

You need to put template inside resources folder. See example in spark, you can see maven's pom resources definitions.

Ori Marko
  • 56,308
  • 23
  • 131
  • 233