velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <>
Subject Re: Finding Templates in Jar files
Date Tue, 13 Nov 2001 08:59:06 GMT
On 11/12/01 5:05 PM, "Terry Steichen" <> wrote:

> This is undoubtably in the dumb question category, but I can't get the
> template files to load from a jar file.
> In, this works fine:
>   file.resource.loader.path =
> /tools/jakarta-tomcat-3.2.2/webapps/w_e/web-inf/spt/templates
>   (in which all templates reside in templates directory)
> But this doesn't work at all:
>   jar.resource.loader.class =
> org.apache.velocity.runtime.resource.loader.JarResourceLoader
>   jar.resource.loader.path =
> jar:file:/tools/jakarta-tomcat-3.2.2/w_e/web-inf/spt/templates/templates.jar
>   (in which the templates.jar is also in the templates directory)
> The velocity log merely says:
>   [error] ResourceManager : unable to find resource 'vnfmain.html' in any
> resource loader.
>   (where vnfmain.html is the first template used).
> I note the appended '\' above and am not sure why that's there, because the
> templates.jar includes each of the templates without any path information
> included.  I am suspicious that this appended backslash is related to my
> problem but don't know how to track it down easily.
> This *should* be so simple - what am I doing wrong?

Not sure if you are showing us everything -

You need a line like :

Resource.loader = jar

To tell the resource manager that 'jar' will be a name of a loader.  What it
then does it try to match things like


Where <foo> == jar

(that's the pattern...)

So that's the first problem if you don't have it.

As an aside, I use the ClasspathResourceLoader all the time in webapps, and
just jar my templates and throw that jar into WEB-INF/lib.  Servlet_example2
in /examples shows how to set this up.


Geir Magnusson Jr.                           
System and Software Consulting
"He who throws mud only loses ground." - Fat Albert

Do You Yahoo!?
Get your free address at

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message