Trouble getting Velocity Tools tools to work as expected

Christopher Schultz <[email protected]> Fri, 2 Jan 2026 15:54:09 -0500
Newsgroups gmane.comp.jakarta.struts.user
Message-ID <[email protected]>
All,

I'm starting a completely new project based upon v7.1.1 and I'd like to 
use both Velocity and the Velocity Tools as well.

I have a *very* simple "hello world" style application with a do-nothing 
action and a test Velocity template.

I can confirm that Velocity is running because I have a few #if 
predicates in there and they aren't rendering as literals, but I think 
I'm not getting the toolbox loaded.

With a simple tools.xml file like this, I'm able to see that 
$date.format("yyyy-MM-dd") will render a date:

<tools>
   <toolbox scope="request">
     <tool class="org.apache.velocity.tools.generic.DateTool"/>
   </toolbox>
</tools>

If I change the scope from "request" to "application", the DateTool is 
no longer available to the request. Is this expected? I'm coming from a 
Struts 1 and VelocityView background where the tools are initialized and 
inserted into the various scopes automatically.

I have a handful of tools that don't need to be instantiated once for 
every request and I'd prefer to keep a single instance of them in the 
application scope. Is that possible without writing a 
ServletContextListener and manually-injecting things into the 
application scope?

-chris