API / Apache FreeMarker Interview questions
How do you troubleshoot a TemplateNotFoundException?
This exception means Configuration.getTemplate() asked every configured TemplateLoader for a template name and none of them could find it. A practical checklist:
| Step | What to check |
| 1 | Confirm the exact template name/path passed to getTemplate() - typos and case mismatches are the most common cause |
| 2 | Verify the TemplateLoader's base path or classpath root actually points at the directory containing the file |
| 3 | Check the file really exists at the resolved location relative to that loader's root, not relative to the working directory |
| 4 | If using MultiTemplateLoader, confirm the intended loader is included and in the expected order |
| 5 | Check localized_lookup - if enabled, FreeMarker may be searching for locale-suffixed variants first |
Turning on FreeMarker's logging (via its logger factory) while reproducing the failure usually shows exactly which candidate paths were probed and why each one missed, which narrows the problem down fast.
More Related questions...