freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]

Spring JIRA | Tokuhiro Matsuno | 3 months ago
  1. 0

    spring.ftl doesn't work on freemarker 2.3.24+'s auto escaping feature

    GitHub | 3 months ago | tokuhirom
    freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]
  2. 0

    spring boot's spring.ftl is using ?html (legacy escaping) in some macros. As a result, if user enables auto escaping feature by *-Dspring.freemarker.settings.output_format=HTMLOutputFormat*, *<@spring.formInput "filter.identityPrincipal", 'size="20" maxlength="20"'/>* throws exception. {code} FreeMarker template error (HTML_DEBUG mode; use RETHROW in production!) Lazy initialization of the imported namespace for "spring.ftl" has failed; see cause exception ---- FTL stack trace ("~" means nesting-related): - Failed at: @spring.formInput "filter.identityPri... [in template "spring_ftl.ftl" at line 4, column 5] ~ Reached through: #nested [in template "__wrapper.ftl" in macro "main" at line 15, column 5] ~ Reached through: @wrapper.main [in template "spring_ftl.ftl" at line 2, column 1] ---- Java stack trace (for programmers): ---- freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...] at freemarker.core.Environment$LazilyInitializedNamespace.ensureInitializedTME(Environment.java:2882) at freemarker.core.Environment$LazilyInitializedNamespace.get(Environment.java:2939) at freemarker.core.Dot._eval(Dot.java:43) at freemarker.core.Expression.eval(Expression.java:81) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:73) at freemarker.core.Environment.visit(Environment.java:363) at freemarker.core.Environment.invokeNestedContent(Environment.java:572) at freemarker.core.BodyInstruction.accept(BodyInstruction.java:60) at freemarker.core.Environment.visit(Environment.java:363) at freemarker.core.Environment.invoke(Environment.java:715) at freemarker.core.UnifiedCall.accept(UnifiedCall.java:83) at freemarker.core.Environment.visit(Environment.java:327) at freemarker.core.Environment.visit(Environment.java:333) at freemarker.core.Environment.process(Environment.java:306) at freemarker.template.Template.process(Template.java:386) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:367) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:284) at org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:234) at org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167) at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303) at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257) at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037) at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980) at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897) at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970) at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861) at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846) at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197) at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) at org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:677) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745) Caused by: freemarker.core.ParseException: Syntax error in template "spring.ftl" in line 225, column 36: Using ?html (legacy escaping) is not allowed when auto-escaping is on with a markup output format (HTML), to avoid double-escaping mistakes. at freemarker.core.FMParser.BuiltIn(FMParser.java:1193) at freemarker.core.FMParser.AddSubExpression(FMParser.java:1101) at freemarker.core.FMParser.PrimaryExpression(FMParser.java:593) at freemarker.core.FMParser.UnaryExpression(FMParser.java:639) at freemarker.core.FMParser.MultiplicativeExpression(FMParser.java:754) at freemarker.core.FMParser.AdditiveExpression(FMParser.java:706) at freemarker.core.FMParser.RangeExpression(FMParser.java:886) at freemarker.core.FMParser.RelationalExpression(FMParser.java:834) at freemarker.core.FMParser.EqualityExpression(FMParser.java:797) at freemarker.core.FMParser.AndExpression(FMParser.java:953) at freemarker.core.FMParser.OrExpression(FMParser.java:975) at freemarker.core.FMParser.Expression(FMParser.java:534) at freemarker.core.FMParser.StringOutput(FMParser.java:1508) at freemarker.core.FMParser.MixedContentElements(FMParser.java:3647) at freemarker.core.FMParser.List(FMParser.java:1731) at freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3329) at freemarker.core.FMParser.MixedContentElements(FMParser.java:3697) at freemarker.core.FMParser.If(FMParser.java:1611) at freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3325) at freemarker.core.FMParser.MixedContentElements(FMParser.java:3697) at freemarker.core.FMParser.Macro(FMParser.java:2630) at freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3352) at freemarker.core.FMParser.MixedContentElements(FMParser.java:3697) at freemarker.core.FMParser.Root(FMParser.java:4280) at freemarker.template.Template.<init>(Template.java:254) at freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:548) at freemarker.cache.TemplateCache.getTemplateInternal(TemplateCache.java:438) at freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:291) at freemarker.template.Configuration.getTemplate(Configuration.java:2438) at freemarker.core.Environment$LazilyInitializedNamespace.initialize(Environment.java:2901) at freemarker.core.Environment$LazilyInitializedNamespace.ensureInitializedTME(Environment.java:2876) ... 66 more {code} Freemarker's current maintainer's comment is here: http://stackoverflow.com/questions/37298463/freemarker-2-3-24-auto-escape-and-spring-ftl-macros-issue ref. http://docs.spring.io/spring/docs/current/spring-framework-reference/html/view.html Here's a reproduce code: https://github.com/tokuhirom/spring-boot-issues-6994

    Spring JIRA | 3 months ago | Tokuhiro Matsuno
    freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]
  3. 0

    Sign Up

    tabletakademi.com | 3 months ago
    freemarker.template.TemplateModelException: [... Exception message was already printed; see it above ...]
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Struts2 REST plugin: Sending JSON object through PUT

    Stack Overflow | 4 years ago | shaunlim
    freemarker.template.TemplateModelException: Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: Error while setting property=com.foo.entity.clientFeature type class java.lang.Object
  6. 0

    Struts2 REST plugin: Passing array in JSON

    Stack Overflow | 4 years ago | shaunlim
    freemarker.template.TemplateModelException: Method public java.lang.String org.apache.commons.lang.exception.NestableRuntimeException.getMessage(int) threw an exception when invoked on net.sf.json.JSONException: Error while setting property=countries type interface java.util.List

    3 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. freemarker.core.ParseException

      Syntax error in template "spring.ftl" in line 225, column 36: Using ?html (legacy escaping) is not allowed when auto-escaping is on with a markup output format (HTML), to avoid double-escaping mistakes.

      at freemarker.core.FMParser.BuiltIn()
    2. FreeMarker
      Template.process
      1. freemarker.core.FMParser.BuiltIn(FMParser.java:1193)
      2. freemarker.core.FMParser.AddSubExpression(FMParser.java:1101)
      3. freemarker.core.FMParser.PrimaryExpression(FMParser.java:593)
      4. freemarker.core.FMParser.UnaryExpression(FMParser.java:639)
      5. freemarker.core.FMParser.MultiplicativeExpression(FMParser.java:754)
      6. freemarker.core.FMParser.AdditiveExpression(FMParser.java:706)
      7. freemarker.core.FMParser.RangeExpression(FMParser.java:886)
      8. freemarker.core.FMParser.RelationalExpression(FMParser.java:834)
      9. freemarker.core.FMParser.EqualityExpression(FMParser.java:797)
      10. freemarker.core.FMParser.AndExpression(FMParser.java:953)
      11. freemarker.core.FMParser.OrExpression(FMParser.java:975)
      12. freemarker.core.FMParser.Expression(FMParser.java:534)
      13. freemarker.core.FMParser.StringOutput(FMParser.java:1508)
      14. freemarker.core.FMParser.MixedContentElements(FMParser.java:3647)
      15. freemarker.core.FMParser.List(FMParser.java:1731)
      16. freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3329)
      17. freemarker.core.FMParser.MixedContentElements(FMParser.java:3697)
      18. freemarker.core.FMParser.If(FMParser.java:1611)
      19. freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3325)
      20. freemarker.core.FMParser.MixedContentElements(FMParser.java:3697)
      21. freemarker.core.FMParser.Macro(FMParser.java:2630)
      22. freemarker.core.FMParser.FreemarkerDirective(FMParser.java:3352)
      23. freemarker.core.FMParser.MixedContentElements(FMParser.java:3697)
      24. freemarker.core.FMParser.Root(FMParser.java:4280)
      25. freemarker.template.Template.<init>(Template.java:254)
      26. freemarker.cache.TemplateCache.loadTemplate(TemplateCache.java:548)
      27. freemarker.cache.TemplateCache.getTemplateInternal(TemplateCache.java:438)
      28. freemarker.cache.TemplateCache.getTemplate(TemplateCache.java:291)
      29. freemarker.template.Configuration.getTemplate(Configuration.java:2438)
      30. freemarker.core.Environment$LazilyInitializedNamespace.initialize(Environment.java:2901)
      31. freemarker.core.Environment$LazilyInitializedNamespace.ensureInitializedTME(Environment.java:2876)
      32. freemarker.core.Environment$LazilyInitializedNamespace.get(Environment.java:2939)
      33. freemarker.core.Dot._eval(Dot.java:43)
      34. freemarker.core.Expression.eval(Expression.java:81)
      35. freemarker.core.UnifiedCall.accept(UnifiedCall.java:73)
      36. freemarker.core.Environment.visit(Environment.java:363)
      37. freemarker.core.Environment.invokeNestedContent(Environment.java:572)
      38. freemarker.core.BodyInstruction.accept(BodyInstruction.java:60)
      39. freemarker.core.Environment.visit(Environment.java:363)
      40. freemarker.core.Environment.invoke(Environment.java:715)
      41. freemarker.core.UnifiedCall.accept(UnifiedCall.java:83)
      42. freemarker.core.Environment.visit(Environment.java:327)
      43. freemarker.core.Environment.visit(Environment.java:333)
      44. freemarker.core.Environment.process(Environment.java:306)
      45. freemarker.template.Template.process(Template.java:386)
      45 frames
    3. Spring MVC
      FrameworkServlet.doGet
      1. org.springframework.web.servlet.view.freemarker.FreeMarkerView.processTemplate(FreeMarkerView.java:367)
      2. org.springframework.web.servlet.view.freemarker.FreeMarkerView.doRender(FreeMarkerView.java:284)
      3. org.springframework.web.servlet.view.freemarker.FreeMarkerView.renderMergedTemplateModel(FreeMarkerView.java:234)
      4. org.springframework.web.servlet.view.AbstractTemplateView.renderMergedOutputModel(AbstractTemplateView.java:167)
      5. org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:303)
      6. org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1257)
      7. org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1037)
      8. org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:980)
      9. org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
      10. org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
      11. org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
      11 frames
    4. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:622)
      1 frame
    5. Spring MVC
      FrameworkServlet.service
      1. org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
      1 frame
    6. JavaServlet
      HttpServlet.service
      1. javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
      1 frame
    7. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      2 frames
    8. Tomcat WS
      WsFilter.doFilter
      1. org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
      1 frame
    9. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      2 frames
    10. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    11. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      2 frames
    12. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.HttpPutFormContentFilter.doFilterInternal(HttpPutFormContentFilter.java:87)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    13. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      2 frames
    14. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:77)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    15. Glassfish Core
      ApplicationFilterChain.doFilter
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      2 frames
    16. Spring
      OncePerRequestFilter.doFilter
      1. org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
      2. org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
      2 frames
    17. Glassfish Core
      CoyoteAdapter.service
      1. org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)
      2. org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)
      3. org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
      4. org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:108)
      5. org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:522)
      6. org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
      7. org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79)
      8. org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
      9. org.apache.catalina.valves.RemoteIpValve.invoke(RemoteIpValve.java:677)
      10. org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349)
      10 frames
    18. Grizzly HTTP
      SocketProcessorBase.run
      1. org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:1110)
      2. org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
      3. org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:785)
      4. org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1425)
      5. org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
      5 frames
    19. Java RT
      ThreadPoolExecutor$Worker.run
      1. java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
      2. java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
      2 frames
    20. Tomcat Util
      TaskThread$WrappingRunnable.run
      1. org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
      1 frame
    21. Java RT
      Thread.run
      1. java.lang.Thread.run(Thread.java:745)
      1 frame