You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Andreas Rückert <a_...@gmx.net> on 2010/02/13 13:46:51 UTC

Problem with velocity 1.6.3 JarResourceLoader

Hi!

Thanks for your great project!

I have a problem however.

I'm trying to write a template code generator for the ArgoUML project, 
using the velocity template processor version 1.6.3. My templates are
in a subdirectory of a jar file. So I use a jar URL, like:

Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".class", "org.apache.velocity.runtime.resource.loader.JarResource$
$rgouml-build/build/argouml.jar!/org/argouml/uml/generator/template/templates/");

The jar is found, but when I load a template from the templates
directory:

Template t = Velocity.getTemplate("sourcefile.vm");

, it's not found.

When I use the complete path:

Template t = Velocity.getTemplate("/org/argouml/uml/generator/template/templates/sourcefile.vm");

, it's found.

Am I correct, that this is a bug? Problem is, that more templates
are included recursively, like

#parse("fileheader.vm")

in sourcefile.vm , and I don't want to include the full path in all
those included templates.

Thanks in advance,
Andreas
-- 
NEU: Mit GMX DSL über 1000,- ¿ sparen!
http://portal.gmx.net/de/go/dsl02

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


Re: Problem with velocity 1.6.3 JarResourceLoader

Posted by Nathan Bubna <nb...@gmail.com>.
On Sat, Feb 13, 2010 at 4:46 AM, "Andreas Rückert" <a_...@gmx.net> wrote:
> Hi!
>
> Thanks for your great project!
>
> I have a problem however.
>
> I'm trying to write a template code generator for the ArgoUML project,
> using the velocity template processor version 1.6.3. My templates are
> in a subdirectory of a jar file. So I use a jar URL, like:
>
> Velocity.setProperty( "jar." + Velocity.RESOURCE_LOADER + ".class", "org.apache.velocity.runtime.resource.loader.JarResource$
> $rgouml-build/build/argouml.jar!/org/argouml/uml/generator/template/templates/");
>
> The jar is found, but when I load a template from the templates
> directory:
>
> Template t = Velocity.getTemplate("sourcefile.vm");
>
> , it's not found.
>
> When I use the complete path:
>
> Template t = Velocity.getTemplate("/org/argouml/uml/generator/template/templates/sourcefile.vm");
>
> , it's found.

No, that's right.  You just need to add a property like this:

jar.resource.loader.path = /org/argouml/uml/generator/template/templates/


> Am I correct, that this is a bug? Problem is, that more templates
> are included recursively, like
>
> #parse("fileheader.vm")
>
> in sourcefile.vm , and I don't want to include the full path in all
> those included templates.
>
> Thanks in advance,
> Andreas
> --
> NEU: Mit GMX DSL über 1000,- ¿ sparen!
> http://portal.gmx.net/de/go/dsl02
>
> ---------------------------------------------------------------------
> 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