API / Apache Velocity Interview questions
What happens when a referenced property or method doesn't exist on an object in a template?
In default lenient mode, Velocity's Uberspector tries to resolve $obj.someProperty as a getter (getSomeProperty()) or public field. If neither exists on the object's class, resolution simply fails silently: the reference renders as its literal text, $obj.someProperty, and rendering continues normally.
No exception propagates up to the calling Java code by default, which means a renamed getter or a typo'd property name can go unnoticed until someone visually spots stray $ text in the output. Velocity does support registering an EventCartridge with an InvalidReferenceEventHandler, which lets you intercept these failures programmatically, for example to log a warning, without switching the whole engine into strict mode.
More Related questions...