How to load a velocity template into an EJB to be used as a mail template

99封情书 提交于 2019-12-06 02:22:18

Velocity can run in any environment, so servlets are not a requirement. It seems that the problem is related to the logging facility, whose default depends on a servlet.

You can use a NullLogChute, or, depending on your logging framework, choose a class implementing LogChute. So for example, if you use commons-logging, you'd need CommonsLogLogChute. How to set it up:

To use, first set up commons-logging, then tell Velocity to use this class for logging by adding the following to your velocity.properties: runtime.log.logsystem.class = org.apache.velocity.runtime.log.CommonsLogLogChute

You may also set this property to specify what log/name Velocity's messages should be logged to (example below is default). runtime.log.logsystem.commons.logging.name = org.apache.velocity

So, apart from providing this setting in velocity.properties, you can call:

engine.setProperty("runtime.log.logsystem.class", 
       "org.apache.velocity.runtime.log.CommonsLogLogChute");
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!