Hi,
I've got the following on a very busy system:
java.lang.Exception: Template.merge() failure. The document is
null, most likely due to parsing error.
This has happened only once in the past few weeks when we generated
hundreds of thousands of messages. Only a couple of VTL templates were
used for the messages. We use velocity 1.4.
The comments in the Velocity source code say "this shouldn't happen
either, but just in case."
What can I do to prevent the exception from happening.
The methods below are copied from our source code. It should provide
some ideas on how we use Velocity.
private String transform(String normalizedName, VtlNotifyData
vtlNotifyData) throws GLException {
StringWriter writer = new StringWriter();
VelocityContext context = vtlNotifyData.getVelocityContext();
Template template = getTemplate(normalizedName);
try {
template.merge(context, writer);
}
catch (Exception e) {
throw GLException.factory(e);
}
return writer.toString();
}
private Template getTemplate(String templateName) throws GLException {
// theNotifyVelocityEngine is a static member
if (theNotifyVelocityEngine == null) {
try {
theNotifyVelocityEngine = new VelocityEngine();
theNotifyVelocityEngine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM,
new VelocityLogSystem());
// set other properties
...
}
theNotifyVelocityEngine.init();
}
catch (Exception e) {
throw GLException.factory(e);
}
}
return theNotifyVelocityEngine.getTemplate(templateName);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]