FreeMarker template error: The following has evaluated to null or missing | BUT NOT TRUE

freemarker null check
freemarker template error null or missing
freemarker core invalidreferenceexception exception message was already printed; see it above
errors due to missing freemarker symbol
if the failing expression is known to legally refer to something that's sometimes null or missing
freemarker error handling
freemarker null check if
freemarker null or empty string

The error I'm facing is so weird. Everything looks fine, but I get this error when the browser sends the GET request to the server. What I'm trying to do is actually catching the HTTP parameters, save them in an object saved in an ArrayList sending to a Freemarker template.

Could you please help me? Thanks a lot.

The error:

freemarker.log._JULLoggerFactory$JULLogger error SEVERE: Error executing FreeMarker template FreeMarker template error: The following has evaluated to null or missing: ==> item.lat1 [in template "view/result.ftl" at line 18, column 15]

freemarker.core.InvalidReferenceException: [... Exception message was already printed; see it above ...] at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:131) at freemarker.core.EvalUtil.coerceModelToString(EvalUtil.java:355) at freemarker.core.Expression.evalAndCoerceToString(Expression.java:82) at freemarker.core.DollarVariable.accept(DollarVariable.java:41) at freemarker.core.Environment.visit(Environment.java:324) at freemarker.core.MixedContent.accept(MixedContent.java:54) at freemarker.core.Environment.visitByHiddingParent(Environment.java:345) at freemarker.core.IteratorBlock$IterationContext.executeNestedBlockInner(IteratorBlock.java:268) at freemarker.core.IteratorBlock$IterationContext.executeNestedBlock(IteratorBlock.java:220) at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:194) at freemarker.core.Environment.visitIteratorBlock(Environment.java:572) at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:78) at freemarker.core.IteratorBlock.accept(IteratorBlock.java:64) at freemarker.core.Environment.visit(Environment.java:324) at freemarker.core.MixedContent.accept(MixedContent.java:54) at freemarker.core.Environment.visit(Environment.java:324) at freemarker.core.Environment.process(Environment.java:302) at freemarker.template.Template.process(Template.java:325) at spark.template.freemarker.FreeMarkerEngine.render(FreeMarkerEngine.java:71) at controller.App.lambda$main$1(App.java:57) at spark.RouteImpl$1.handle(RouteImpl.java:58) at spark.webserver.MatcherFilter.doFilter(MatcherFilter.java:162) at spark.webserver.JettyHandler.doHandle(JettyHandler.java:61) at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:189) at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141) at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:119) at org.eclipse.jetty.server.Server.handle(Server.java:517) at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:302) at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:242) at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:245) at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:95) at org.eclipse.jetty.io.SelectChannelEndPoint$2.run(SelectChannelEndPoint.java:75) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceAndRun(ExecuteProduceConsume.java:213) at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:147) at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:654) at org.eclipse.jetty.util.thread.QueuedThreadPool$3.run(QueuedThreadPool.java:572) at java.lang.Thread.run(Thread.java:745)

[qtp285763673-17] ERROR spark.webserver.MatcherFilter - java.lang.IllegalArgumentException: freemarker.core.InvalidReferenceException: The following has evaluated to null or missing: ==> item.lat1 [in template "view/result.ftl" at line 18, column 15]

.. But true, because I do print the Array and it works fine!

  final FreeMarkerEngine freeMarkerEngine = new FreeMarkerEngine();
    final Configuration freeMarkerConfiguration = new Configuration();
    freeMarkerConfiguration.setTemplateLoader(new ClassTemplateLoader(App.class, "/"));
    freeMarkerEngine.setConfiguration(freeMarkerConfiguration);

    get("/rest", (request, response) -> {
        Double lat1 = Double.parseDouble(request.queryParams("lat1") != null ? request.queryParams("lat1") : "anonymous");
        Double lon1 = Double.parseDouble(request.queryParams("lon1") != null ? request.queryParams("lon1") : "anonymous");
        Double lat2 = Double.parseDouble(request.queryParams("lat2") != null ? request.queryParams("lat2") : "anonymous");
        Double lon2 = Double.parseDouble(request.queryParams("lon2") != null ? request.queryParams("lon2") : "anonymous");

        if (shouldReturnHtml(request)) {
            response.status(200);
            response.type("text/html");
            Map<String, Object> attributes = new HashMap<>();
            attributes.put("list",loadTheList(lat1,lon1,lat2,lon2));
            return freeMarkerEngine.render(new ModelAndView(attributes, "/view/result.ftl"));
        }
        else {
            response.status(200);
            response.type("application/json");
            return null;
        }
    });


}

private static boolean shouldReturnHtml(Request request) {
    String accept = request.headers("Accept");
    return accept != null && accept.contains("text/html");
}
public static ArrayList<Bereken> loadTheList(double lat1, double lon1, double lat2, double lon2) {
    ArrayList<Bereken> list = new ArrayList<>();
    list.add(new Bereken(lat1,lon1,lat2,lon2));
    return list;
}

And result.ftl:

      <#list list as item>
        <h2>${item.lat1}</h2>
        <h2>${item.lon1}</h2>
        <h2>${item.lat2}</h2>
        <h2>${item.lon2}</h2>
    </#list>

You are adding 1 instance of the Bereken class to the "list". So i would assume the Bereken class does not provide public properties lat1, lat2, lon1, lon2 or coresponding getter methods.

5.1 FreeMarker template error: The following has e, 5.1 FreeMarker template error: The following has evaluated to null or missing System has been fine since the multi tenancy was enabled - ie:no errors logged operator to fallback to an empty string if there is no data - but it is You can correct it by editing the template document specified by the NodeRef�

I know this is an old question, but I just bumped into this. Freemarker will also complain that the value "is null or missing" if you pass it an instance of a private class (which I just tried). If you pass in a Java Bean class, it needs to be public. The error message is very misleading in this case.

Error handling, FreeMarker template error: The following has evaluated to null or missing #118. Closed. uniqueid001 opened this issue on Aug 28, 2015 � 2 comments. Closed�

I just ran across this yesterday. I was working through a tutorial and one of the steps did not include the code for a getter method in a class that created an object. I guess the author just assumed the reader knew that should have happened already.

So, wherever this 'Bereken' thing is (I just learned it is a JavaBean class), be sure to add the setter and getter methods for the properties associated with each element in the 'list'.

The following has evaluated to null or missing: in template , FreeMarker template error: The following has evaluated to null or missing well, but when adding the template, the frequent null pointer problem. refer to something that's sometimes null or missing, either specify a default value of null pointers in the front --> <prop key="classic_compatible">true</prop>�

Document type properties evaluating to null or missing in template , FreeMarker has to load the template into the memory and parse it (unless HTML_DEBUG_HANDLER : Same as DEBUG_HANDLER , but it If an error occurs in an interpolation which is not inside an FTL tag (that is, not enclosed into <#. Handling missing/null variables: Template Author's Guide/The�

java, Not Logged In. Log in. WW-5051. The following has evaluated to null or missing: in template But in Ubuntu OS, its giving issues. (_Log4jLoggerFactory.java: error:59) Error executing FreeMarker template FreeMarker�

关于java:FreeMarker模板错误:以下内容评估为null或缺少| 但是不是 , InvalidReferenceException: The following has evaluated to null or missing” error. doesn't have a null check, but does exist in my document, is “null or missing”. WARN [HstFreemarkerServlet] Error in Freemarker template: [INFO] It's the step after the last dot that caused this error, not those before it.