3

we are creating a schema with a component link and component link is using same schema. now while reading the component in EntityController we are not getting the component link data.

enter image description here

Model Class code

    @Data
    @EqualsAndHashCode(callSuper = true)
    @SemanticEntity(entityName = "Instructions", vocabulary = SDL_CORE, prefix = "in")
    public class Instructions extends AbstractEntityModel {
        @SemanticProperty("in:SubTitle")
        @JsonProperty("SubTitle")
        private String subTitle;
        
        @SemanticProperty("in:Title")
        @JsonProperty("Title")
        private String title;
        
        @SemanticProperty("in:PDFFile")
        @JsonProperty("PDFFile")
        private BinaryItem pdfFile;
        
        @SemanticProperty("in:ChildInstructions")
        @JsonProperty("ChildInstructions")
        private List<Instructions> childInstructions;
    }

Entity Controller code

} else if(model != null && model instanceof Instructions) {
        Instructions tempModel = (Instructions)model;
        return tempModel;
    }

JSON Preview from CME

{
   "Id":"133089-133108",
   "Namespace":"tcm",
   "ComponentTemplate":{
      "Id":"133108",
      "Namespace":"tcm",
      "Title":"Instructions Details",
      "RevisionDate":"2022-01-13T11:24:02",
      "OutputFormat":"HTML Fragment",
      "Metadata":{
         "controller":"Generic:Generic",
         "view":"Generic:InstructionDetails",
         "regionView":"Generic:WebInstructionLinks"
      }
   },
   "Folder":{
      "Id":"17456",
      "Title":"001 First Law"
   },
   "Content":{
      "SubTitle":"First: The Law:",
      "Title":"Summary of the Provisions of Chapter Three of the Law No. 32 of 1968 concerning Currency, the Central Bank of Kuwait and the Organisation of Banking Business, and other Ministerial Resolutions and Related Provisions.",
      "PDFFile":{
         "$type":"EntityModelData",
         "Id":"2749",
         "Namespace":"tcm",
         "ComponentTemplate":{
            "Id":"126337",
            "Namespace":"tcm",
            "RevisionDate":"0001-01-01T00:00:00"
         },
         "Folder":{
            "Id":"1003",
            "Title":"CBK Instructions to Conventional Banks"
         },
         "BinaryContent":{
            "Url":"/Preview/en/images/instructions-issued-in-connection-with-the-organization-of-local-banks-investment-policy-2749_v30_tcm10-2749.pdf",
            "FileName":"instructions-issued-in-connection-with-the-organization-of-local-banks-investment-policy-2749_v30.pdf",
            "FileSize":159808,
            "MimeType":"application/pdf"
         },
         "SchemaId":"25"
      },
      "Style":"Bullet point Link",
      "ChildInstructions":{
         "$type":"EntityModelData",
         "Id":"133090",
         "Namespace":"tcm",
         "ComponentTemplate":{
            "Id":"126337",
            "Namespace":"tcm",
            "RevisionDate":"0001-01-01T00:00:00"
         },
         "Folder":{
            "Id":"17456",
            "Title":"001 First Law"
         },
         "Content":{
            "Title":"Center of Risks System and Regulations Issued for its Implementation",
            "PDFFile":{
               "$type":"EntityModelData",
               "Id":"2732",
               "Namespace":"tcm"
            },
            "Style":"Bullet point Link",
            "ChildInstructions":{
               "$type":"EntityModelData",
               "Id":"133128",
               "Namespace":"tcm"
            }
         },
         "Metadata":{
            "childInstructionIds":"133128",
            "lastModifiedDate":"2022-01-19T10:15:44.3098017"
         },
         "SchemaId":"133088"
      }
   },
   "MvcData":{
      "ControllerName":"Generic",
      "ControllerAreaName":"Generic",
      "ViewName":"InstructionDetails",
      "AreaName":"Generic"
   },
   "XpmMetadata":{
      "ComponentID":"tcm:10-133089",
      "ComponentModified":"2022-01-19T10:15:30",
      "ComponentTemplateID":"tcm:10-133108-32",
      "ComponentTemplateModified":"2022-01-13T11:24:02",
      "IsRepositoryPublished":true
   },
   "Metadata":{
      "childInstructionIds":"133090",
      "lastModifiedDate":"2022-01-19T10:15:30.0532647"
   },
   "SchemaId":"133088"
}

Error in log

ERROR c.s.w.c.i.mapping.SemanticMapperImpl - Exception while getting field data for: private java.util.List com.sdl.dxa.modules.generic.model.Instructions.childInstructions
com.sdl.webapp.tridion.fields.exceptions.FieldConverterException: Cannot convert a entity model 133090 to class com.sdl.dxa.modules.generic.model.Instructions for semantic field ChildInstructions
    at com.sdl.dxa.tridion.mapping.converter.EntityModelDataConverter.convert(EntityModelDataConverter.java:43)
    at com.sdl.dxa.tridion.mapping.converter.EntityModelDataConverter.convert(EntityModelDataConverter.java:17)
    at com.sdl.dxa.tridion.mapping.converter.GenericSemanticModelDataConverter.convert(GenericSemanticModelDataConverter.java:65)
    at com.sdl.dxa.tridion.mapping.impl.DefaultSemanticFieldDataProvider.getFieldData(DefaultSemanticFieldDataProvider.java:135)
    at com.sdl.webapp.common.impl.mapping.SemanticMapperImpl$1.doWith(SemanticMapperImpl.java:126)
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:693)
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:673)
    at com.sdl.webapp.common.impl.mapping.SemanticMapperImpl.createEntity(SemanticMapperImpl.java:105)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.createViewModel(DefaultModelBuilder.java:157)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.buildEntityModel(DefaultModelBuilder.java:123)
    at com.sdl.dxa.tridion.mapping.impl.ModelBuilderPipelineImpl.createEntityModel(ModelBuilderPipelineImpl.java:86)
    at com.sdl.dxa.tridion.mapping.impl.ModelBuilderPipelineImpl.createEntityModel(ModelBuilderPipelineImpl.java:73)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.createEntityModel(DefaultModelBuilder.java:360)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.lambda$createRegionModel$10(DefaultModelBuilder.java:342)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.forEach(Unknown Source)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.createRegionModel(DefaultModelBuilder.java:345)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.lambda$buildPageModel$8(DefaultModelBuilder.java:266)
    at java.util.stream.ReferencePipeline$3$1.accept(Unknown Source)
    at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(Unknown Source)
    at java.util.stream.AbstractPipeline.copyInto(Unknown Source)
    at java.util.stream.AbstractPipeline.wrapAndCopyInto(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(Unknown Source)
    at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(Unknown Source)
    at java.util.stream.AbstractPipeline.evaluate(Unknown Source)
    at java.util.stream.ReferencePipeline.forEach(Unknown Source)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.buildPageModel(DefaultModelBuilder.java:267)
    at com.sdl.dxa.tridion.mapping.impl.ModelBuilderPipelineImpl.createPageModel(ModelBuilderPipelineImpl.java:59)
    at com.sdl.dxa.tridion.mapping.impl.DefaultContentProvider._loadPage(DefaultContentProvider.java:104)
    at com.sdl.dxa.tridion.mapping.impl.DefaultContentProvider.getPageModel(DefaultContentProvider.java:175)
    at com.sdl.webapp.common.controller.PageController.getPageModel(PageController.java:290)
    at com.sdl.webapp.common.controller.PageController.handleGetPage(PageController.java:119)
    at com.sdl.dxa.modules.generic.controller.GenericPageController.handleGetPage(GenericPageController.java:123)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:97)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
    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:635)
    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at com.tridion.ambientdata.web.AbstractAmbientDataServletFilter.doFilter(AbstractAmbientDataServletFilter.java:291)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    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:193)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:496)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
    at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:650)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
    at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:479)
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1468)
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
    at java.lang.Thread.run(Unknown Source)
Caused by: com.sdl.webapp.common.exceptions.DxaException: Exception happened while creating a entity model from: EntityModelData(id=133090, componentTemplate=ComponentTemplateData(id=126337, title=null, revisionDate=0001-01-01T00:00:00.000Z, outputFormat=null, metadata=null), linkUrl=, content={Title=Center of Risks System and Regulations Issued for its Implementation, PDFFile=EntityModelData(id=2732, componentTemplate=null, linkUrl=, content=null, binaryContent=null, externalContent=null), Style=Bullet point Link}, binaryContent=null, externalContent=null)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.buildEntityModel(DefaultModelBuilder.java:133)
    at com.sdl.dxa.tridion.mapping.impl.ModelBuilderPipelineImpl.createEntityModel(ModelBuilderPipelineImpl.java:86)
    at com.sdl.dxa.tridion.mapping.converter.EntityModelDataConverter.convert(EntityModelDataConverter.java:37)
    ... 84 common frames omitted
Caused by: com.sdl.webapp.common.exceptions.DxaException: Cannot get a view model tpe because of semantic mapping exception
    at com.sdl.webapp.common.impl.model.ViewModelRegistryImpl.getMappedModelTypes(ViewModelRegistryImpl.java:109)
    at com.sdl.webapp.common.impl.model.ViewModelRegistryImpl.getMappedModelTypes(ViewModelRegistryImpl.java:78)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:333)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:190)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
    at org.springframework.cache.interceptor.CacheInterceptor$1.invoke(CacheInterceptor.java:52)
    at org.springframework.cache.interceptor.CacheAspectSupport.invokeOperation(CacheAspectSupport.java:345)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:408)
    at org.springframework.cache.interceptor.CacheAspectSupport.execute(CacheAspectSupport.java:327)
    at org.springframework.cache.interceptor.CacheInterceptor.invoke(CacheInterceptor.java:61)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
    at com.sun.proxy.$Proxy95.getMappedModelTypes(Unknown Source)
    at com.sdl.dxa.tridion.mapping.impl.DefaultModelBuilder.buildEntityModel(DefaultModelBuilder.java:107)
    ... 86 common frames omitted
Caused by: com.sdl.webapp.common.api.mapping.semantic.SemanticMappingException: Ambiguous semantic mapping for http://www.sdl.com/web/schemas/core:Instructions, found these mappings: [class com.sdl.dxa.modules.generic.model.Instructions, class com.sdl.dxa.modules.generic.model.Instructions]
    at com.sdl.webapp.common.impl.mapping.SemanticMappingRegistryImpl.getEntityClassByFullyQualifiedName(SemanticMappingRegistryImpl.java:334)
    at com.sdl.webapp.common.impl.model.ViewModelRegistryImpl.getMappedModelTypes(ViewModelRegistryImpl.java:107)
    ... 103 common frames omitted
9
  • In the CME preview the page R2 JSON output and update in your question for review.
    – Velmurugan
    Jan 18, 2022 at 7:54
  • @Velmurugan I have updated the question with the JSON output from CME preview. Jan 19, 2022 at 9:06
  • if you just want only the component link data then you can use it in your model private List<Link> childInstructions; this will get your link information. the component link will be resolved in the graphical side by model extension by default.
    – Velmurugan
    Jan 19, 2022 at 17:04
  • The error message shows Ambiguous semantic mapping for class com.sdl.dxa.modules.generic.model.Instructions double-check this one.
    – Velmurugan
    Jan 19, 2022 at 17:06
  • 1
    The ambiguous semantic mapping error may stem from the fact that your Instructions class has a SemanticEntity annotation which mimics the default semantics (entityName = class name in SDL_CORE vocabulary). Try removing that SemanticEntity annotation altogether; if the default semantics are okay for you, you don't need this annotation. Jan 26, 2022 at 16:20

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.