When trying to list all properties of a Document in a Freemarker template view (for loggin purpose) using the ?keys builtin (since a Document is a Hash in Freemarker), there is a ClassCastException (see below).
To patch it, reimplement DocumentTemplate.keys()
from
return (TemplateCollectionModel) wrapper.wrap(getRawKeys());
to
return new CollectionAndSequence(new SimpleSequence(getRawKeys(), wrapper));
and it should do the trick.
Caused by: java.lang.ClassCastException:
freemarker.template.SimpleSequence cannot be cast to freemarker.template.TemplateCollectionModel
at org.nuxeo.ecm.platform.rendering.fm.adapters.DocumentTemplate.keys(DocumentTemplate.java:89)
at freemarker.core.BuiltIn$keysBI._getAsTemplateModel(BuiltIn.java:588)
at freemarker.core.Expression.getAsTemplateModel(Expression.java:89)
at freemarker.core.IteratorBlock.accept(IteratorBlock.java:94)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.MixedContent.accept(MixedContent.java:92)
at freemarker.core.Environment.visit(Environment.java:208)
at freemarker.core.Environment.process(Environment.java:188)
at org.nuxeo.ecm.platform.rendering.fm.FreemarkerEngine.render(FreemarkerEngine.java:183) ... 66 more