contrib/scripting/velocity VelocityTemplatesScriptEngineFactory needs workaround in case of engine instantiation errors -----------------------------------------------------------------------------------------------------------------------
Key: SLING-1702 URL: https://issues.apache.org/jira/browse/SLING-1702 Project: Sling Issue Type: Improvement Components: Scripting Environment: Felix 1.4, Sling 2.0.7, Apache Velocity 1.6.2 Reporter: Olaf Otto Affects: Rev. 989119 of https://svn.apache.org/repos/asf/sling/trunk/contrib/scripting/velocity (2.0.0-SNAPSHOT) The (terrible!) Sun implementation of javax.script.ScriptEngineManager silently discards all exceptions thrown when a scripting factory creates an engine: ... private static final boolean DEBUG = false; ... } catch (Exception exp) { if (DEBUG) exp.printStackTrace(); } This hides any error with the velocity configuration from the user. Thus the VelocityTemplatesScriptEngineFactory should provide a log-and-re-throw workaround, like so: ... import org.slf4j.Logger; import org.slf4j.LoggerFactory; ... private final Logger logger = LoggerFactory.getLogger(getClass()); public ScriptEngine getScriptEngine() { ScriptEngine engine; try { engine = new VelocityTemplatesScriptEngine(this); } catch (RuntimeException e) { logger.error("Unable to instantiate the velocity template engine.", e); throw e; } return engine; } -- This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.