Rudy
Rudy

Reputation: 7044

Cannot resolve template loader path Freemarker

I use freemarker with Spring.

This is the way I configure my freemarker :

<bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">     
    <property name="templateLoaderPath" value="classpath:/META-INF/templates"/>    
</bean> 

This configuration is actually working fine, I am able to generate my report using the templates, etc.

However in Weblogic, I always get this Exception :

15 Sep 2012 01:03:02,060 DEBUG DefaultListableBeanFactory.doCreateBean:504 - Eagerly caching bean 'freemarkerConfiguration' to allow for resolving potential circular references
15 Sep 2012 01:03:02,074 DEBUG DefaultListableBeanFactory.invokeInitMethods:1498 - Invoking afterPropertiesSet() on bean with name 'freemarkerConfiguration'
15 Sep 2012 01:03:02,228 DEBUG FreeMarkerConfigurationFactoryBean.getTemplateLoaderForPath:360 - Cannot resolve template loader path [classpath:/META-INF/templates] to [java.io.File]: using SpringTemplateLoader as fallback
java.io.FileNotFoundException: class path resource [META-INF/templates] cannot be resolved to absolute file path because it does not reside in the file system: zip:C:/Oracle/Middleware/user_projects/domains/gppuser/servers/GPPFilesBCSIS/tmp/_WL_user/GPPFilesBCSIS/phxni8/war/WEB-INF/lib/_wl_cls_gen.jar!/META-INF/templates
at org.springframework.util.ResourceUtils.getFile(ResourceUtils.java:204)
at org.springframework.core.io.AbstractFileResolvingResource.getFile(AbstractFileResolvingResource.java:52)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.getTemplateLoaderForPath(FreeMarkerConfigurationFactory.java:351)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactory.createConfiguration(FreeMarkerConfigurationFactory.java:304)
at org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean.afterPropertiesSet(FreeMarkerConfigurationFactoryBean.java:60)

This Error actually happens during the loading. Anyone know how to solve and remove this Exception? The file is actually still generated using the templates provided, so I'm not really sure what this error about.

For your info : I'm not using exploded deployment.

Upvotes: 2

Views: 10744

Answers (1)

ddekany
ddekany

Reputation: 31122

This is nothing to worry about. Note that the log level is DEBUG, not ERROR or WARNING.

When the template directory is accessible through java.io.File (because it's not inside a jar, war, etc.), Spring will configure FreeMarker to use java.io.File directly to load the templates, because that way FreeMarker can check the last modification times and automatically reload templates. To find out if the path can be mapped to a plain directory, Spring will call Resource.getFile() and see if it throws IOException. If it did, Spring logs with DEBUG level, then configures FreeMarker to load the templates through Spring's Resource abstraction (without using Resource.getFile of course). So it's the normal program flow in your case.

Upvotes: 9

Related Questions