PebbleTemplates / pebble

Java Template Engine
https://pebbletemplates.io
BSD 3-Clause "New" or "Revised" License
1.09k stars 166 forks source link

Could not found template ! problem with quarkus #600

Open noorguesmi opened 3 years ago

noorguesmi commented 3 years ago

Hey there!

i'm tryin to use pebble template in quarkus project! i put my pebble file in ressource/templates. after setting the path this way PebbleTemplate compiledTemplate = engine.getTemplate("templates/cra.peb"); and running the project i got this error : com.mitchellbosecke.pebble.error.LoaderException: Could not find template "templates/cra.peb" (?:?) Does anyone know what seems to be wrong ? been stuck for a while and i don't know how to proceed to correct this error, i would appreciate some help.

Thanks in advance.

decebals commented 3 years ago

I have the same error message but the context is different. The problem in my case is that the error appears from time to time but the template is rendered somehow (I cannot explain this - maybe two successive fast request for the same template).

2021-08-20 09:24:45 ERROR DefaultErrorHandler:186 - Could not find template "users" (?:?)
com.mitchellbosecke.pebble.error.LoaderException: Could not find template "users" (?:?)
    at com.mitchellbosecke.pebble.loader.DelegatingLoader.getReader(DelegatingLoader.java:69)
    at com.mitchellbosecke.pebble.loader.DelegatingLoader.getReader(DelegatingLoader.java:24)
    at com.mitchellbosecke.pebble.PebbleEngine.getPebbleTemplate(PebbleEngine.java:151)
    at com.mitchellbosecke.pebble.PebbleEngine.lambda$getTemplate$1(PebbleEngine.java:146)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1705)
    at com.mitchellbosecke.pebble.cache.template.ConcurrentMapTemplateCache.computeIfAbsent(ConcurrentMapTemplateCache.java:24)
    at com.mitchellbosecke.pebble.cache.template.ConcurrentMapTemplateCache.computeIfAbsent(ConcurrentMapTemplateCache.java:9)
    at com.mitchellbosecke.pebble.PebbleEngine.getTemplate(PebbleEngine.java:146)
    at com.mitchellbosecke.pebble.PebbleEngine.getTemplate(PebbleEngine.java:117)
    at ro.pippo.pebble.PebbleTemplateEngine.renderResource(PebbleTemplateEngine.java:149)
    at ro.pippo.core.Response.renderToString(Response.java:1057)
    at ro.pippo.core.Response.render(Response.java:1023)

Related to above stacktrace, in the end is executed engine.getTemplate(templateName) (where engine is an instance of PebbleEngine).

I use Java 11 and Pebble 3.0.5.

decebals commented 3 years ago

I found the problem in my case. It's something wrong in our code.