personally, i think Markos gave you the best answer already.  you
should use the WebappLoader from the VelocityTools project.  The
FileResourceLoader that Velocity uses by default is not very webapp
friendly.  there are ways to get it working in web applications, but
in general they are not obvious and not portable.  use the
WebappLoader instead and what you're doing below should work fine.

On Mon, 21 Feb 2005 22:31:27 -0800, Michael Salmon <[EMAIL PROTECTED]> wrote:
> hi folks
> 
> my templates don't load from where I want. In particular here is what
> I'm doing:
> 
> 1. servlet extends VelocityServlet. and calls Velocity.init(). I dont
> override loadConfiguration()
> 
> 2. In my webapp, web.xml I define the specific properties file:
>     <param-name>org.apache.velocity.properties</param-name>
>     <param-value>/WEB-INF/velocity.properties</param-value>
> 
>     I'm pretty sure the right velocity.properties file is being loaded,
>     because when I change the name it spits an error in the log.
> 
> 4. In the properties file I define:
> 
>     file.resource.loader.path = /WEB-INF/templates/
> 
> 5. In my servlet I do:
>     getTemplate("Test.vm");
> 
>     /www/element/WEB-INF/templates/Test.vm - this file exists
> 
> 6. catalina.log - org.apache.velocity.exception.ResourceNotFoundException: 
> Unable to find resource 'Test.vm'
> 
> I found that from where I launch tomcat is where velocity
> wants to load templates from. It seems clear to me my loader.path is not
> being setup correctly. For now until I have a better solution I'll just
> have to launch tomcat from my webapp root and put my templates there.. Still
> I'd love to have a proper solution.
> 
> Thanks,
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to