You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by David Ehrmann <eh...@gmail.com> on 2010/03/11 22:13:25 UTC

Can't get WebappResourceLoader to load

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.

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?  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.

Thanks in advance,

David

Re: Can't get WebappResourceLoader to load

Posted by Nathan Bubna <nb...@gmail.com>.
On Thu, Mar 11, 2010 at 1:13 PM, David Ehrmann <eh...@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