Caused by: java.lang.ClassNotFoundException: freemarker.cache.TemplateLoader
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 63 more
During the deployment of the app, I see the freemarker-2.3.19.jar loaded. See below.
INFO 2012-05-25 22:50:00,890 [Mule.app.deployer.monitor.1.thread.1] org.mule.module.launcher.MuleApplicationClassLoader: [dartmouth-server] Loading the following jars:
=============================
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/aopalliance-1.0.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/cglib-nodep-2.1_3.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/commons-logging-1.1.1.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/dartmouth-common.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/freemarker-2.3.19.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/guava-r09.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/jaxb-api-2.2.5.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/jaxb2-basics-0.6.0.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/jaxb2-basics-runtime-0.6.0.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/jaxb2-basics-tools-0.6.0.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/jedis-2.0.0.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/spring-asm-3.1.1.RELEASE.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/spring-context-support-3.1.1.RELEASE.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/spring-core-3.1.1.RELEASE.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/spring-data-redis-1.0.0.RC1.jar
file:/Users/athieme/mule-standalone-3.2.1/apps/dartmouth-server/lib/spring-tx-3.1.0.RC1.jar
=============================
It's freemarker-2.3.19.jar that contains freemarker.cache.TemplateLoader. See below.
11:28 PM dartmouth> jar tvf ~/mule/apps/dartmouth-server/lib/freemarker-2.3.19.jar |grep "freemarker.cache.TemplateLoader"
445 Thu Mar 01 01:10:00 EST 2012 freemarker/cache/TemplateLoader.class
11:28 PM dartmouth>
In my Mule/Spring configuration, I have the following.
<spring:bean id="freemarkerConfig" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean">
<spring:property name="templateLoaderPath" value="classpath:com/athieme/"/>
</spring:bean>
As a separate test, I created a very small, non-Mule Maven project that includes the required dependancies to inject the Freemarker Configuration object. Here's that pom.xml. When I run code from this project, Freemarker is called correctly.
<?xml version="1.0" encoding="UTF-8"?>
<modelVersion>4.0.0</modelVersion>
<groupId>com.athieme</groupId>
<artifactId>simple-spring-maven</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<org.springframework>3.1.1.RELEASE</org.springframework>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${org.springframework}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${org.springframework}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context-support</artifactId>
<version>${org.springframework}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.19</version>
</dependency>
</dependencies>
</project>
Here's (basically) the Java code to call Freemarker; although, Mule never gets this far because the Mule/Spring config never loads completely.
final StringWriter result = new StringWriter();
final Template template = configuration.getTemplate("password.ftl");
final Message message = new Message();
java.util.Map map = new java.util.HashMap();
map.put("message", message);
template.process(map, result);
String str = result.toString();
System.out.println(str);