At line 98 added 46 lines. |
__UPDATE:__ I solved all of these issues by implementing Velocity's WebappLoader rather than the one from Roller. Here's the code I used to initialize it: |
{{{ |
/** |
* Key used to access the ServletContext in the Velocity application attributes. |
*/ |
public static final String SERVLET_CONTEXT_KEY = ServletContext.class.getName(); |
|
//~ Methods ================================================================ |
|
public void init(PageContext pageContext, MenuDisplayerMapping mapping) { |
super.init(pageContext, mapping); |
this.pageContext = pageContext; |
|
// MR: Copied from VelocityViewServlet to initialize WebappLoader |
Velocity.setApplicationAttribute(SERVLET_CONTEXT_KEY, |
pageContext.getServletContext()); |
|
// default to servletlogger, which logs to the servlet engines log |
Velocity.setProperty(RuntimeConstants.RUNTIME_LOG_LOGSYSTEM_CLASS, |
ServletLogger.class.getName()); |
|
// by default, load resources with webapp resource loader |
Velocity.setProperty(RuntimeConstants.RESOURCE_LOADER, "webapp"); |
Velocity.setProperty("webapp.resource.loader.class", |
WebappLoader.class.getName()); |
|
// now all is ready - init Velocity |
try { |
ResourceBundle rb = ResourceBundle.getBundle("velocity"); |
|
Properties props = new Properties(); |
|
for (Enumeration keys = rb.getKeys();keys.hasMoreElements();) { |
String key = (String) keys.nextElement(); |
props.put(key, rb.getString(key)); |
} |
|
// only initialized the first time it's called, from: |
// http://jakarta.apache.org/velocity/developer-guide.html |
// it's ignored for subsequent calls |
Velocity.init(props); |
} catch (Exception e) { |
log.error("Error initializing Velocity: " + e.getMessage()); |
e.printStackTrace(); |
} |
}}}} |