Freemarker: Loading templates from different locations
<p>I am trying to load templates for Freemarker from 2 different places.  The folders where the ftl files are located are:</p>

<pre><code>/docroot/WEB-INF/src/charts/base
/docroot/WEB-INF/src/charts/tmpl
</code></pre>

<p>I have the following class with 2 methods:</p>

<pre><code>public class TemplateLoader {

    public Template loadChartBaseTemplate(String templateName) throws Exception {

        String templateFile = String.format("%s.ftl", templateName);

        Configuration cfg = new Configuration();
        cfg.setClassForTemplateLoading(this.getClass(), "/charts/base/");
        Template template = cfg.getTemplate(templateFile);

        return template;

    }

    public Template loadChartTemplate(String fileName) throws Exception {

        Configuration cfg = new Configuration();
        cfg.setClassForTemplateLoading(this.getClass(), "/charts/tmpl/");
        Template template = cfg.getTemplate(fileName);

        return template;

    }

}
</code></pre>

<p>The first method loads the templates properly.  The second method returns an error saying "Template not found for name ".  Both folders are at the same level and I checked that the files I am trying to load exist.</p>

<p>What may cause Freemarker to be able to load the templates from one folder and fail for the other, given that they are at the same level (I tried with the ending "/" and without it and it makes no difference, the behavior is the same).</p>

<p>One additional question:  </p>

<p>The following lines return the error: The constructor Configuration() is deprecated</p>

<pre><code>Configuration cfg = new Configuration();
</code></pre>

<p>All documentation and examples I have seen have it like this.  Is there other way of doing this?</p>

<p>Thanks in advance for all your help.</p>