BriteSnow / snow

A Lightweight, Google Guice, Simple, and Powerful Web Application Framework that makes building modern Web Application a breeze! Fully open source, Apache V2 licensed.
http://britesnow.com/snow
29 stars 10 forks source link

Cannot locate template files #42

Closed Ueland closed 10 years ago

Ueland commented 10 years ago

Hi,

I have a private project which have been running fine for weeks. When i was about to start todays work on the project, i was greeted by this message upon server start:

Could not find template in cache, creating new one; id=["home/thu/[projectName]/src/main/webapp/_frame.ftl"["en_US",UTF-8,parsed] ] Error while rendering freemarker template /_frame (/home/thu/[projectName]/src/main/webapp/_frame.ftl) because Template "/home/thu/[projectName]/src/main/webapp/_frame.ftl" not found. java.io.FileNotFoundException: Template "/home/thu/[projectName]/src/main/webapp/_frame.ftl" not found. at freemarker.template.Configuration.getTemplate(Configuration.java:742) at freemarker.template.Configuration.getTemplate(Configuration.java:665) at com.britesnow.snow.web.renderer.freemarker.FreemarkerTemplateRenderer.render(FreemarkerTemplateRenderer.java:157) at com.britesnow.snow.web.Application.processTemplate(Application.java:169)

I thought it was a simple matter of a missing file, but the file is there, and the permissions has not changed. (Still readable for my user)

thu@thu:~$ stat /home/thu/[projectName]/src/main/webapp/_frame.ftl File: `/home/thu/[projectName]/src/main/webapp/_frame.ftl' Size: 7298 Blocks: 16 IO Block: 4096 regular file Device: fc01h/64513d Inode: 4198308 Links: 1 Access: (0664/-rw-rw-r--) Uid: ( 1000/ thu) Gid: ( 1000/ thu) Access: 2014-05-24 21:15:10.634498692 +0200 Modify: 2014-05-24 20:49:15.416418849 +0200 Change: 2014-05-24 21:15:09.166498654 +0200 Birth: - thu@thu:~$

I have now tested with both the 2.0.2 and the 2.0.3 release, the same thing is happening on both releases. I also tried to remove my maven cache, starting the project both from IntelliJ and Maven, but the error persists.

I tried running a debugger against Configuration.java, and it appears that Freemarker is removing the first slash in the URL, which causes the template path to become: "home/thu/[projectName]/src/main/webapp/_frame.ftl", which of course does not exist.

Any ideas on what this might be, and how i can move forward?

Ueland commented 10 years ago

Did a new dig with the debugger now. TemplateCache.java (Freemarker 2.3.20), line 200 does a normalizeName, which removes the first slash from an absolute path, as mentioned above.

Ueland commented 10 years ago

i deleted .m2/repository, the project and checked it out again, and suddenly everything is ok. Magic :)

Could not find template in cache, creating new one; id=["home/thu/[projectName]/src/main/webapp/_frame.ftl"["en_US",UTF-8,parsed] ] Compiling FreeMarker template "home/thu/[projectName]/src/main/webapp/_frame.ftl"["en_US",UTF-8,parsed] from "/home/thu/[projectName]/src/main/webapp/_frame.ftl" Could not find template in cache, creating new one; id=["home/thu/[projectName]/src/main/webapp/index.ftl"["en_US",UTF-8,parsed] ] Compiling FreeMarker template "home/thu/[projectName]/src/main/webapp/index.ftl"["en_US",UTF-8,parsed] from "/home/thu/[projectName]/src/main/webapp/index.ftl" "home/thu/[projectName]/src/main/webapp/_frame.ftl"["en_US",UTF-8,parsed] cached copy not yet stale; using cached.

jeremychone commented 10 years ago

Thanks for closing this one.