velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: Resource from a jar file
Date Mon, 15 Jun 2009 20:37:23 GMT
Can you put your jar in the classpath and use the
ClasspathResourceLoader instead of going through the file system?
I've never used the JarResourceLoader, and i haven't really got time
to dig in and see why it isn't working for you right now...

On Sun, Jun 14, 2009 at 11:21 AM, Mark Fenbers<Mark.Fenbers@noaa.gov> wrote:
> 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
>
>

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


Mime
View raw message