Velocity engine fails to load template from a remote shared folder
- by performanceuser
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?