I'm constantly struggling with NoSuchFileException while trying to reach templates for HandleBars template engine for Vertx. Personally i think that ether Vertx file system root is inconsistent or I'm missing something, code snippet is following:
String templateLocation = "templates"+File.separator+"index.hbs";
fs = vertx.fileSystem();
fs.exists(templateLocation, existHandler -> {
if(existHandler.succeeded() && existHandler.result() == true){
engine.render(context,templateLocation, renderResult -> {
if (renderResult.succeeded()) {
context.request().response().putHeader("Content-Type", "text/html");
context.response().end(renderResult.result());
} else {
context.fail(renderResult.cause());
}
});
Firs, I'm confirming via exist, does directory and template file exist. If yes, them start render action on same directory, I'm falling into:
java.nio.file.NoSuchFileException: \emplates\index.hbs
Event though FileSystem claims directory exist.
Where do HandleBars expect then to find it's templates?
I'm already copy/paste folder templates/index.hbs
to all possible locations:
- Project root
- src/resources
- directory where java main is executed
all with no success...
Also please notice missing t
in exception, is not a typo, looks like something in the stack is not handling very well paths