velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nathan Bubna <nbu...@gmail.com>
Subject Re: Can't get WebappResourceLoader to load
Date Fri, 26 Mar 2010 18:19:20 GMT
On Thu, Mar 11, 2010 at 1:13 PM, David Ehrmann <ehrmann@gmail.com> wrote:
> I'm having problems getting Templates from a WAR file to load.  Thanks to my
> debugger, I traced it down to not seeing WebappResourceLoader in the
> VelocityEngine's internal resource loader list; all I saw was a
> FileResourceLoader.

right.  it's in VelocityTools

> Here's how I'm initializing Velocity:
>
> In my Servlet's init() method, I do:
>
> ve = new VelocityEngine();
> ve.setApplicationAttribute("javax.servlet.ServletContext",
> this.getServletContext());
> ve.init();
>
> I tried setting the attribute both before and after init.  No change.
>
> My web.xml file has the servlet defined like this:
>
> <servlet>
> <servlet-name>mySite</servlet-name>
> <servlet-class>...mySite</servlet-class>
>   <init-param>
>     <param-name>org.apache.velocity.properties</param-name>
>     <param-value>/WEB-INF/velocity.properties</param-value>
>   </init-param>
> </servlet>
>
> When I look at .../TomcatRoot/webapps/ROOT/WEB-INF/velocity.properties, it
> exists.
>
> And my velocity.properties file:
>
> resource.loader=webapp
> webapp.resource.loader.class=org.apache.velocity.tools.view.WebappResourceLoader
> webapp.resource.loader.path=/WEB-INF/templates/
>
> directive.foreach.counter.initial.value = 0
>
> Am I missing a step?  Did I get the initialization order right?

looks ok to me.

>  I couldn't
> find WebappResourceLoader, so after some searching, I saw that it was in
> Velocity Tools...until I realized it also wasn't in there, so I switched
> to velocity-tools-view-2.0-beta4.jar.  Velocity is velocity-1.6.3.jar.

In VelocityTools 1.x, the WebappResourceLoader is at:

org.apache.velocity.tools.view.servlet.WebappLoader

Use that if you'd prefer to avoid a beta release.

> Thanks in advance,
>
> David
>

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


Mime
View raw message