velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: WebappResourceLoader: ResourceNotFoundException
Date Tue, 20 Jan 2009 22:07:42 GMT
On Sun, Jan 18, 2009 at 8:18 AM, Kai Schlichting <laccolithgrunt@gmx.de> wrote:
> Hi!
>
> I tried to get Velocity working with WebappResourceLoader for a web project.
> My current code:
>
> Properties props = new Properties();
> props.setProperty("resource.loader=webapp", "webapp");

this is wrong.  do:

props.setProperty("resource.loader", "webapp");

> props.setProperty("webapp.resource.loader.class",
> "org.apache.velocity.tools.view.WebappResourceLoader");
> props.setProperty("webapp.resource.loader.path",
> "/WEB-INF/classes/my/package");
> VelocityEngine ve = new VelocityEngine(props);

before you init, you have to do:

ve.setApplicationAttribute("javax.servlet.ServletContext",
yourServletContextObject);

> ve.init();
> Template t = ve.getTemplate( "my.template.vm" );
>
> I only want to use Velocity right now at one place and would like to set the
> properties in the code (with no configuration file). Although "C:\Program
> Files\Apache Software Foundation\Tomcat
> 6.0\webapps\my_project\WEB-INF\classes\my\package\my.template.vm" exists, I
> get a ResourceNotFoundException when calling getTemplate - what am I doing
> wrong?
>
> Thx!
>

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


Mime
View raw message