You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Cliff Meyers <cl...@gmail.com> on 2005/08/10 21:15:57 UTC

locating Velocity templates in a .jar

I wrote a single class that is used to generate UI for our web
applications.  I wanted to package this class in a .jar along with the
two velocity templates it depends on.  Unfortunately I can't get this
call in my class to work:

Template template = Velocity.getTemplate(templateFile);

Is there something I can set in the properties file
(file.resource.loader.path) that will assist me here?  Is the approach
even possible?  Thanks so much for your help!


-Cliff Meyers

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


RE: locating Velocity templates in a .jar

Posted by Michael Oliver <ol...@alariussystems.com>.
Ah ha!  Use the ClassPathResourceLoader instead of the default
FileResourceLoader and make sure your jar is in the classpath and if the
location of the templates in the jar is
/com/yourpackage/templates/....blahblay.vm

Your reference to it should be com/yourpackage/templates/...blahblay.vm

It took me two days to figure that out....just slow I guess, I hope this
helps you do it faster.

Michael Oliver
CTO
Alarius Systems LLC
6800 E. Lake Mead Blvd, #1096
Las Vegas, NV 89156
Phone:(702)643-7425
Fax:(702)974-0341
*Note new email changed from oliverm@matrix-media.com
-----Original Message-----
From: Cliff Meyers [mailto:cliff.meyers@gmail.com] 
Sent: Wednesday, August 10, 2005 12:16 PM
To: velocity-user@jakarta.apache.org
Subject: locating Velocity templates in a .jar

I wrote a single class that is used to generate UI for our web
applications.  I wanted to package this class in a .jar along with the
two velocity templates it depends on.  Unfortunately I can't get this
call in my class to work:

Template template = Velocity.getTemplate(templateFile);

Is there something I can set in the properties file
(file.resource.loader.path) that will assist me here?  Is the approach
even possible?  Thanks so much for your help!


-Cliff Meyers

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



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