[Actionframework-users] bug in VelocityInOutVariable for multiple servlets
Status: Inactive
Brought to you by:
ptoman
From: Mark D. A. <md...@di...> - 2002-09-16 02:15:50
|
If there are multiple servlets in a container using the actionframework, things don't work. Only the first servlet finds its templates. At least part of the problem is that VelocityInOutVariable has a static variable "ri" which holds a shared org.apache.velocity.runtime.RuntimeInstance (at least if using Velocity 1.2). This is a problem, because RuntimeInstance is the thing that holds the ResourceManagerImpl which holds the FileResourceLoader which holds the search path for templates. Since it is initialized in VelocityInOutVariable in a static clause, no servlet after the first one will ever get its own FileResourceLoader for finding templates. So far as I can make out, fixing this will require changes in a number of places. actionframework's VelocityServlet.java cannot just call its base class's getTemplate() method as that relies on velocity's RuntimeSingleton, which would introduce the same problem. Rather, I think engine/velocity/VelocityServlet.java's loadConfiguration should also instantiate a velocity RuntimeInstance itself. That ri should be used for getTemplate. Furthermore, VelocityInOutVariable's constructor should be changed to either take that ri in its constructor args, or it should cast the ActionServlet to a VelocityServlet and call a getter on it to get the ri. -mda |