Hi,

I am new to this mailing list and am using velocity in my current
project. I am facing a problem providing a template to velocity engine.
The code is listed below:

VelocityContext context = new VelocityContext(); 
context.put("OfferLetterDTO", objOfferLetterDTO); 
Template template = null; 

            try 
            { 
                System.out.println((new
File(templateFile)).getAbsolutePath() + (new
File(templateFile)).exists()); 
               [b] template = Velocity.getTemplate(templateFile);[/b] 
            } catch (ResourceNotFoundException rnfe) 
            { 
                System.out.println("CreateAttachmentFromTemplate : error
: cannot find template " + templateFile); 
            } catch (ParseErrorException pee) 
            { 
                System.out.println("CreateAttachmentFromTemplate :
Syntax error in template " + templateFile + ":" + pee); 
            }




The problem is with the line "template =
Velocity.getTemplate(templateFile);" 
If a pass an absolute path, lets say, "E:\Resource\templates\a.html",
the error that I get is "ResourceNotFoundException" though the file
actually exists in the same path. The same code works fine if I give a
relative path. I am using JBoss and its trying to find the template file
relative to "{JBoss-home}/bin". 
Is there any way that i can pass an absolute path to this method. The
velocity API says the getTemplate(java.lang.String name) method 
"Returns a Template from the Velocity resource management system." and I
fail to understand what "Velocity resource management system" means. 

Hope that someone can help find a solution. 

Thanks in advance.

 

Regards,

Shivani

Reply via email to