Re: Loading FTL templates from JAR in maven

Vijay <[email protected]> Wed, 25 Dec 2013 07:26:02 -0800 (PST)
Newsgroups gmane.comp.web.freemarker.devel
Message-ID <[email protected]>
Hi Daniel,

Th eproblem I have is the controller class which I am using is in a
package(com.test.freemarker) and the template jar file is loaded from
repository by defining in pom.xml. So the template JAR file is available
under maven dependencies in my STS.
After complete application build the controller class file is in different
jar and template files are in different jar. 

PFB the code snippet. 

Configuration Class in  com.test.freemarker package.

protected Configuration createConfiguration() {

    config = super.createConfiguration();
    config.setClassForTemplateLoading(getClass(), "/");
    
    return config;
}

There are multiple folders in template JAR in which I need to traverse to
get the template file. 

Code snippet for reading template file:

try{

Template template = getConfiguration().getTemplate("/<template jar
name>/WEB-INF/freemarker/sample.ftl");

} catch(Exception e) {

}
In this case I am getting file not found. 
Also I tried loading using various combinations by not providing the jar
name etc.,.
But nothing seems to work. 
Can you please help me in resolving this. 



--
View this message in context: http://freemarker.624813.n4.nabble.com/Loading-FTL-templates-from-JAR-in-maven-tp4654896p4654904.html
Sent from the freemarker-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT 
organizations don't have a clear picture of how application performance 
affects their revenue. With AppDynamics, you get 100% visibility into your 
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349831&iu=/4140/ostg.clktrk