I just ran into a problem in the combination of
FreeMarker, Sitemesh, Spring and a custom
TemplateLoader (in my case from DB via Hibernate/Spring).
The Problem is the init() method of FreemarkerServlet
in combination with the private configuration variable.
What I do is, I extend
which extends the FreemarkerServlet itself.
In my class I want to inject a Spring
by overriding the createConfiguration() method of
But the init() method of the FreeMarkerServlet messes
around with my configuration, mainly it tries to set a
templatePath (which I don't have, because I load from DB).
It is not an option to overwrite init(), because the
configuration variable is private and I have no way to
set it myself.
The solution is to refactor the FreemarkerServlet a
bit, move some parts out of init into protected methods
(to allow customization in subclasses) and to make some
of the variables protected instead of private.