Document type properties evaluating to null or missing in template

EDIT - All @ characters removed from code snippets to pass new member mention validation *

I’m in need of help with properties set up in a new document type, which isn’t being rendered on my page (FTL template) and giving the “freemarker.core.InvalidReferenceException: The following has evaluated to null or missing” error.

For the purposes of showing the problem, I’ve reduced my FTL template, which was based on the Essentials Carousel template, to just displaying two properties - a title and image. The eventual template and document type will have many more properties, but after running into my issue I removed most to simplify debugging.

My template:

<#include "include/imports.ftl">
<#include "include/setdevglobals.ftl">


<#-- ftlvariable name="componentId" type="java.lang.String" -->
<#-- ftlvariable name="item" type="com.eb.cms.beans.Banner" -->
<#-- ftlvariable name="pageable" type="org.onehippo.cms7.essentials.components.paging.Pageable" -->
<#-- ftlvariable name="cparam" type="org.onehippo.cms7.essentials.components.info.EssentialsCarouselComponentInfo" -->
<#if pageable?? && pageable.items?has_content>
    <div class="slide">
        <#list pageable.items as item>

            <p>>> ${item.title} <<</p>

            <#if item.bannerimage??>
                <hst.link var="img" hippobean=item.bannerimage />
                <#assign cleanimg = img?remove_beginning("/_cmsinternal")>
            </#if>

            <#if cleanimg?? && cleanimg?has_content>
               <p> >> ${cleanimg} <<</p>
            </#if>

            <#if hstRequest.queryString?? && hstRequest.queryString?contains('carouseldebug=true')>
                <#import "include/debugger.ftl" as debugger>
                <debugger.debug debugObject=item depth=2 />
            </#if>
        </#list>
    </div>


<#elseif editMode>
  <div>
    <img src="<hst.link path='/images/essentials/catalog-component-icons/carousel.png'/>"> Click to edit Carousel
  </div>
  <div class="has-new-content-button">
    <hst.manageContent templateQuery="new-banner-document" parameterName="document1" rootPath="banners"/>
  </div>
</#if>

My page has a carousel component, which is configured in the console to use the above template.

I created a new document type, with Super type as “basedocument”. The document type has only two properties, a Title (type: String, path: title) and Image (type: Image Link, path: bannerimage). After creating the document type I generated template queries and set up allowed content. I then used the Bean Writer to generate HST Content beans. This is the resulting Java class:

package com.eb.cms.travel.beans;

import org.onehippo.cms7.essentials.dashboard.annotations.HippoEssentialsGenerated;
import org.hippoecm.hst.content.beans.Node;
import com.eb.cms.travel.beans.BannerImageSet;

HippoEssentialsGenerated(internalName = "travelcms2:HomePageBanner")
Node(jcrType = "travelcms2:HomePageBanner")
public class HomePageBanner extends BaseDocument {
    HippoEssentialsGenerated(internalName = "travelcms2:title")
    public String getTitle() {
        return getProperty("travelcms2:title");
    }

    HippoEssentialsGenerated(internalName = "travelcms2:bannerimage")
    public BannerImageSet getBannerimage() {
        return getLinkedBean("travelcms2:bannerimage", BannerImageSet.class);
    }
}

I uploaded a new image and created a document using my new document type, giving it a title and choosing my newly uploaded image. I saved and published my document.

I then in the Channel Manager add my carousel component to the page, and as the first carousel item I choose my new page and then publish the changes.

My problem is now that neither the title or image is being displayed on page. This is the resulting HTML snippit:

<div class="slide">

    <p>>>  <<</p>

</div>

And this is the error displayed in the log, where it indicates that the title property, which doesn’t have a null check, but does exist in my document, is “null or missing”.

[WARNING] [talledLocalContainer] %d{HH:mm:ss} WARN  [HstFreemarkerServlet] Error in Freemarker template:
[INFO] [talledLocalContainer] freemarker.core.InvalidReferenceException: The following has evaluated to null or missing:
[INFO] [talledLocalContainer] ==> item.title  [in template "webfile:/freemarker/eb/homepage-banner-short.ftl" at line 13, column 21]
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] ----
[INFO] [talledLocalContainer] Tip: It's the step after the last dot that caused this error, not those before it.
[INFO] [talledLocalContainer] ----
[INFO] [talledLocalContainer] Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
[INFO] [talledLocalContainer] ----
[INFO] [talledLocalContainer]
[INFO] [talledLocalContainer] ----
[INFO] [talledLocalContainer] FTL stack trace ("~" means nesting-related):
[INFO] [talledLocalContainer]   - Failed at: ${item.title}  [in template "webfile:/freemarker/eb/homepage-banner-short.ftl" at line 13, column 19]
[INFO] [talledLocalContainer] ----
[INFO] [talledLocalContainer]   at freemarker.core.InvalidReferenceException.getInstance(InvalidReferenceException.java:134) ~[freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.EvalUtil.coerceModelToTextualCommon(EvalUtil.java:451) ~[freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.EvalUtil.coerceModelToStringOrMarkup(EvalUtil.java:374) ~[freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.DollarVariable.calculateInterpolatedStringOrMarkup(DollarVariable.java:96) ~[freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.DollarVariable.accept(DollarVariable.java:59) ~[freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.visit(Environment.java:362) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.IteratorBlock$IterationContext.executeNestedContent(IteratorBlock.java:263) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.IteratorBlock$IterationContext.accept(IteratorBlock.java:200) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.visitIteratorBlock(Environment.java:595) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.IteratorBlock.acceptWithResult(IteratorBlock.java:81) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.IteratorBlock.accept(IteratorBlock.java:67) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.visit(Environment.java:326) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.visit(Environment.java:332) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.visit(Environment.java:332) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.core.Environment.process(Environment.java:305) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.ext.servlet.FreemarkerServlet.processEnvironment(FreemarkerServlet.java:910) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.ext.servlet.FreemarkerServlet.process(FreemarkerServlet.java:879) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at freemarker.ext.servlet.FreemarkerServlet.doGet(FreemarkerServlet.java:764) [freemarker-2.3.24-incubating.jar:2.3.24]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.servlet.HstFreemarkerServlet.doGet(HstFreemarkerServlet.java:153) [hst-client-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:635) [servlet-api.jar:?]
[INFO] [talledLocalContainer]   at javax.servlet.http.HttpServlet.service(HttpServlet.java:742) [servlet-api.jar:?]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:728) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationDispatcher.doInclude(ApplicationDispatcher.java:591) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationDispatcher.include(ApplicationDispatcher.java:527) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstComponentInvokerImpl.invokeDispatcher(HstComponentInvokerImpl.java:443) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstComponentInvokerImpl.invokeRender(HstComponentInvokerImpl.java:250) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at sun.reflect.GeneratedMethodAccessor380.invoke(Unknown Source) ~[?:?]
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.logging.HstComponentInvokerProfiler.profile(HstComponentInvokerProfiler.java:60) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at sun.reflect.GeneratedMethodAccessor250.invoke(Unknown Source) ~[?:?]
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.MethodInvocationProceedingJoinPoint.proceed(MethodInvocationProceedingJoinPoint.java:85) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.PersistableSessionAroundAdvice.invoke(PersistableSessionAroundAdvice.java:68) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at sun.reflect.GeneratedMethodAccessor249.invoke(Unknown Source) ~[?:?]
[INFO] [talledLocalContainer]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_151]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethodWithGivenArgs(AbstractAspectJAdvice.java:627) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AbstractAspectJAdvice.invokeAdviceMethod(AbstractAspectJAdvice.java:616) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.aspectj.AspectJAroundAdvice.invoke(AspectJAroundAdvice.java:70) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213) [spring-aop-4.3.15.RELEASE.jar:4.3.15.RELEASE]
[INFO] [talledLocalContainer]   at com.sun.proxy.$Proxy117.invokeRender(Unknown Source) [?:?]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.AggregationValve.processWindowsRender(AggregationValve.java:449) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.AggregationValve.invoke(AggregationValve.java:252) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.ComponentRenderingValve.invoke(ComponentRenderingValve.java:34) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.PageCachingValve.invoke(PageCachingValve.java:62) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.ESIPageInfoScanningValve.invoke(ESIPageInfoScanningValve.java:80) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.PageInfoRenderingValve.invoke(PageInfoRenderingValve.java:50) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.ResourceServingValve.invoke(ResourceServingValve.java:40) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.ActionValve.invoke(ActionValve.java:47) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.LocalizationValve.invoke(LocalizationValve.java:101) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.ContextResolvingValve.invoke(ContextResolvingValve.java:115) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.JCRSessionStatefulConcurrencyValve.invoke(JCRSessionStatefulConcurrencyValve.java:56) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.SubjectBasedSessionValve.invoke(SubjectBasedSessionValve.java:58) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.SecurityValve.invoke(SecurityValve.java:177) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.CmsSecurityValve.invoke(CmsSecurityValve.java:88) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.InitializationValve.invoke(InitializationValve.java:49) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline$Invocation.invokeNext(HstSitePipeline.java:288) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline.invokeValves(HstSitePipeline.java:173) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstSitePipeline.invoke(HstSitePipeline.java:155) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.core.container.HstRequestProcessorImpl.processRequest(HstRequestProcessorImpl.java:79) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.container.HstDelegateeFilterBean.processResolvedSiteMapItem(HstDelegateeFilterBean.java:671) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.container.HstDelegateeFilterBean.doFilter(HstDelegateeFilterBean.java:364) [hst-core-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.container.DelegatingFilter.doFilter(DelegatingFilter.java:84) [hst-commons-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.hippoecm.hst.container.HstFilter.doFilter(HstFilter.java:51) [hst-commons-5.3.0.jar:5.3.0]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [catalina.jar:8.5.34]
[INFO] [talledLocalContainer]   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [catalina.jar:8.5.34]

I suspect the problem lies with my document type, because if I create another document with the default banner document type, which also has a title property and matching path, and add that document as the second item in my carousel, the title is being displayed on the page:

<div class="slide">

    <p>>>  <<</p>

    <p>>> Test document <<</p>

</div>

Something else that might give a clue, is that when I change my template to print out “item”, instead of “item.title”, I get the following:

<div class="slide">

    <p>>> org.hippoecm.hst.content.beans.standard.HippoDocument524d1f7 <<</p>


    <p>>> com.eb.cms.travel.beans.Banner489c7f75 <<</p>


</div>

I suspect my problem lies with item in my new document type being “org.hippoecm.hst.content.beans.standard.HippoDocument”, but I have no idea why or how to resolve it. I see the same when adding debug to the page.

Lastly, I am able to get the title using an ugly workaround in my template:

${item.property["travelcms2:title"]}

This works for my document type, as well as the default banner type.

<div class="slide">

    <p>>> Travel Sorted <<</p>

    <p>>> Test document <<</p>

</div>

This is not something I want to resort to, and doesn’t work for compound fields like the image anyway.

Some other things I have tried without success is making a copy of the default banner document type, creating a document type with unique property paths not used in any other document type and inserting my document into a different single banner (not carousel) component.

Can anyone point me to where I have gone wrong please?

Is it possible you haven’t compiled after generating the bean?

Thanks for your response, @jasper.floor.

If by compiled you mean running mvn verify and mvn -Pcargo.run ..., I did. If I browse the site target folder, I can see the compiled class file in the beans folder.

I have redone the document type creation, bean generation and compiling multiple times, thinking I might have skipped a step that is causing it to fail, every time with the same result. I have tried with different document type names, different property names, making copies of existing document types and creating new ones.

Hi,

I think the symptom suggests the following:

  • The item bean refers to the the document content node properly, resolving the location exactly.
  • However, the bean object should have been a HomePageBanner, not HippoDocument. If you can fix it somehow to return HomePageBanner object, then your template will be able to retrieve the title property from the class’s getter method, getTitle().

Now, why could it not resolve the document node to the proper, specific bean type in your case? Here’s some possible cases:

  • For some reason, the document content node located at ${item.path} is not of the node type, travelcms2:HomePageBanner that you specified with in the HomePageBanner class’s @Node annotation. In that case, HST cannot convert the content node to the bean type properly. Take a look at the ‘published’ (live) variant node at ${item.path} in CMS console. The @jcr:primaryType property. Or print it with ${item.node.primaryNodeType.name} in FM template.
  • Or, check hst-beans-annotated-classes context-param in site/src/main/webapp/WEB-INF/web.xml. It should contain something like classpath*:com/eb/**/*.class. Otherwise, HST won’t scan your bean classes and so won’t map content to those beans.

Regards,

Woonsan

1 Like

I have looked into your suggestions, and all looks as expected.

Looking at the published variant node in the console, for the new (not working) document type:

image

And for the old (working) document type:

image

I also printed ${item.node.primaryNodeType.name} to the template, alongside the item and item.title for both carousel items.

Template:

<div class="slide">
    <#list pageable.items as item>

        <p><strong>item.node.primaryNodeType.name:</strong> ${item.node.primaryNodeType.name}</p>

        <p><strong>item:</strong> ${item}</p>

        <p><strong>item.title:</strong> ${item.title}</p>

        <p>-------</p>

        ...

    </#list>
</div>

Output:

<div class="slide">

    <p><strong>item.node.primaryNodeType.name:</strong> travelcms2:HomePageBanner</p>

    <p><strong>item:</strong> org.hippoecm.hst.content.beans.standard.HippoDocument524d1f7</p>

    <p><strong>item.title:</strong> </p>

    <p>-------</p>


    <p><strong>item.node.primaryNodeType.name:</strong> travelcms2:bannerdocument</p>

    <p><strong>item:</strong> com.ebucks.cms.travel.beans.Banner489c7f75</p>

    <p><strong>item.title:</strong> Test document</p>

    <p>-------</p>


</div>

Lastly I checked the web.xml:

<context-param>
<param-name>hst-beans-annotated-classes</param-name>
<param-value>classpath*:com/eb/cms/travel/**/*.class
  ,classpath*:org/onehippo/**/*.class
  ,classpath*:com/onehippo/**/*.class
  ,classpath*:org/onehippo/forge/**/*.class
</param-value></context-param>

The document type bean class is indeed located at site/target/classes/com/eb/cms/travel/beans/HomePageBanner.class

Any duplicate classes with the same @Node(jcrType = "travelcms2:HomePageBanner") annotation?

Woonsan

Searching my whole project using my IDE, only finds one instance of @Node(jcrType = "travelcms2:HomePageBanner"), in HomePageBanner.java

You might want to enable debug level logging for org.hippoecm.hst.util.ObjectConverterUtils, the addJcrPrimaryNodeTypeClassPair() method of which can leave debug logging for problematic classes on startup.

You can also watch the ObjectConverter instance (from HstRequestContext#getObjectConverter() in an HstComponent) in the debugger. o.h.hst.content.beans.manager.ObjectConverterImpl#jcrPrimaryNodeTypeBeanPairs is the internal map for primary node type name vs Java mapping class.

If nothing found during the scanning/registration process, you can debug org.hippoecm.hst.content.beans.manager.ObjectConverterImpl#getObject(Node), in which the node-to-bean mapping happens in the end.

Regards,

Woonsan

I’ve added the debug logging and looked for all you mentioned in the log files.

I am however not a backend dev, so might not have done it 100% correct, so please confirm if what I did is what you meant.

I added <Logger name="org.hippoecm.hst.util.ObjectConverterUtils" level="debug" /> to the log4j2 config, rebuilt, started up the app and loaded my page, and searched the logs in target/tomcat8x/logs for any mention of the methods you specified. I found none.

I then added <Logger name="org.hippoecm.hst.content.beans.manager.ObjectConverterImpl" level="debug" /> to the log4j2 config, and looked in the log for anything printed regarding mapping, both during app start and reloading my page. Again I found nothing.

What purpose does setting the ftlvariable serve in the FTL templates? I notice that it does not match my class name or path where my document class is located.

<#-- ftlvariable name="item" type="com.eb.cms.beans.Banner" -->

vs

site/target/classes/com/eb/cms/travel/beans/HomePageBanner.class

I do however see that other document types that work correctly also don’t match, sp not sure if it really matters. I have tried changing it in my template to exactly match my class and path, which doesn’t solve my issue. I just want to be 100% sure this won’t add to my problem.

ftlvariable is mostly for whoever is writing the template. Intellij can use it to offer code completion, other ide’s may as well. It’s just a convention and has no meaning for the runtime.

1 Like

I think you’ve mentioned that you’re testing in preview mode (perhaps inside channel manager).
What happens if you test it in live mode? Of course, after publishing all the linked documents and by visiting the live site in your browser.

Woonsan

All my testing is done on published documents in the browser. All I did in the channel manager was add the carousel component to my page and configured it to use my document.

If you rebuilt and ran mvn -P cargo.run, conf/log4j2-dev.xml will be effective, not conf/log4j2-dist.xml.
In debug level logging, I thought you could have warnings (in debug level) from [1] and [2] in logs/hippo-site.log or command line console. But there might be other issues.

Are you using 12.x?

Woonsan

[1] https://code.onehippo.org/cms-community/hippo-site-toolkit/blob/hst-5.6.0/content-beans/src/main/java/org/hippoecm/hst/util/ObjectConverterUtils.java#L305
[2] https://code.onehippo.org/cms-community/hippo-site-toolkit/blob/hst-5.6.0/content-beans/src/main/java/org/hippoecm/hst/content/beans/manager/ObjectConverterImpl.java#L197

1 Like

And, just in case, could you also test with a newly created and published HomePageBanner document, to rule out any potential version history issue?

Woonsan

And do a mvn clean verify. Sometimes clean needs to be run.

I’m using 12.6.0. I asked a colleague who is still on 12.3.0 to try, and he is experiencing the same. I’m considering creating a Git branch from a time and version that we last created and used document types successfully, to determine if sometime went wrong with an upgrade at some point. I think a few upgrades were done on our application since the last time we had to add a new document type.

Correct, this is the one I edited

I asked my colleague to create his own test document type and document, on his own local machine and Git branch, to rule out any issue with my local or branch. He had the same problem.

This I do quite often, especially after checking out a different Git branch, or undoing changes I have made. This unfortunately doesn’t help with this issue.

Thanks for this, this pointed me to the problem:

07.01.2019 10:48:00 DEBUG http-nio-8080-exec-10 [ObjectConverterImpl.getObject:171] No bean found for travelcms2:HomePageBanner, using fallback class class org.hippoecm.hst.content.beans.standard.HippoDocument instead

So knowing now that the problem is that the bean for my document type isn’t found, I looked more at this. After again running both mvn clean verify and mvn -Pcargo.run I can confirm that it is in :

site/src/main/java/com/eb/cms/travel/beans/HomePageBanner.java

and :

site/target/classes/com/eb/cms/travel/beans/HomePageBanner.class

but NOT in :

target/tomcat8x/webapps/ROOT/WEB-INF/classes/com/eb/cms/travel/beans/

From what I can see, this is where the site runs from locally, so this is likely why it is not found. Am I correct in my thinking? I can see classes for other working document types in that location

What could cause the class not to be there, even though it is in the first two locations, even after doing a recompile?

Since it does go into your target then it is getting compiled. Cargo should take the compiled war and deploy it to tomcat. I see you are deploying to ROOT. This is not the default behavior. Check your cargo profile to make sure you are deploying correctly. You may be grabbing an old artifact.

1 Like

Thank you so much @woonsanko and @jasper.floor, issue solved.

We actually do deploy to ROOT, using maven-assembly and the following config:

<file>
  <source>site/target/site.war</source>
  <outputDirectory>webapps</outputDirectory>
  <destName>ROOT.war</destName>
</file>  

This has been working in our production site since mid last year, and I know we have created new working document types since, so wasn’t the problem.

This was the answer. When looking at the generated site.war, I saw last modified date was a few months back, even though I have been recompiling often. It turns out none of the modules were compiling.

It seems someone here made a change in the project parent POM at some point, which changed how we should compile ( i.e. should now be in non-standard way), without communicating the change.

Thanks for your insights, they guided me to the solution.