Velocity engine fails to load template from a remote shared folder
Posted
by
performanceuser
on Stack Overflow
See other posts from Stack Overflow
or by performanceuser
Published on 2013-11-08T05:35:58Z
Indexed on
2013/11/08
21:54 UTC
Read the original article
Hit count: 209
I have following code
File temlateFile = new File( "D:/config/emails/MailBody.vm" );
temlateFile.exists();
VelocityEngine velocityEngine = new VelocityEngine();
velocityEngine.setProperty(RuntimeConstants.RESOURCE_LOADER, "file");
velocityEngine.setProperty("file.resource.loader.class", FileResourceLoader.class.getName());
velocityEngine.setProperty("file.resource.loader.path", temlateFile.getParentFile().getAbsolutePath());
velocityEngine.init();
template = velocityEngine.getTemplate( temlateFile.getName() );
This works because it is loading a file from local file system.
Once I change the first like to:
File temlateFile = new File( "//remote/config/emails/MailBody.vm" );
It doesn't work.
org.apache.velocity.exception.ResourceNotFoundException: Unable to find resource 'MailBody.vm'
at org.apache.velocity.runtime.resource.ResourceManagerImpl.loadResource(ResourceManagerImpl.java:474)
at org.apache.velocity.runtime.resource.ResourceManagerImpl.getResource(ResourceManagerImpl.java:352)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1533)
at org.apache.velocity.runtime.RuntimeInstance.getTemplate(RuntimeInstance.java:1514)
at org.apache.velocity.app.VelocityEngine.getTemplate(VelocityEngine.java:373)
at com.actuate.iserver.mail.VelocityContent.<init>(VelocityContent.java:33)
at com.actuate.iserver.mail.VolumeCreationMail.<init>(VolumeCreationMail.java:40)
at com.actuate.iserver.mail.VolumeCreationMail.main(VolumeCreationMail.java:67)
In both cases temlateFile.exists() always return true.
Any ideas?
© Stack Overflow or respective owner