velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Fenbers <Mark.Fenb...@noaa.gov>
Subject Re: Resource from a jar file
Date Sun, 14 Jun 2009 18:21:52 GMT
Nathan Bubna wrote:
> You can configure multiple resource loaders in a lookup order.
>
> resource.loader=jar,file,whatever
> jar.resource.loader.class = ...
> file.resource.loader.class = ...
> whatever.resource.loader.class = ...
>
> if Velocity can't find it via the jar one, it'll ask the file one,
> then the whatever one, and so on until it runs out of loaders to ask.
> Only then will it throw a ResourceNotFoundException.
>   
Good to know this.  My velocity.properties file now looks like this:

resource.loader = jar,file
jar.resource.loader.class = 
org.apache.velocity.runtime.resource.loader.JarResourceLoader
jar.resource.loader.path = jar:file:templates.jar
file.resource.path = /

So now I am able to get past the Velocity.init() method without any 
thrown exceptions regardless how I'm running my app (jar, JVM, Eclipse, 
etc.).  But when my app reaches the mergeTemplate() method, I get a 
ResourceNotFoundException:

org.apache.velocity.exception.ResourceNotFoundException: Unable to find 
resource 'file:/home/oper/workspace/GIFTS/templates.jar!/SHEF.6hr.template'

when I run from the Jar file, but do not get it if running from JVM or 
Eclipse.  My /home/oper/workspace/GIFTS/templates.jar file looks like this:

7332 Mon May 04 08:14:20 EDT 2009 SHEF.6hr.template

(among other entries).  So despite the error, the jar file it complains 
about exists at the location given, and it also contains the template 
file that it squawks about.  So I'm not sure what I'm doing wrong and 
why the resource cannot be found when it exists right where is says it 
is looking. 

Any ideas? I'm using v1.6.2.

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org


Mime
View raw message