I'm installing DD4T Java on Tridion Sites 10.
DD4T's version is 2.1.12.
There is no DD4T Java for Sites10 on the Github, so I use dd4t-bom-tridion-9 as a test.
https://github.com/dd4t/dd4t-2-java/tree/develop/dd4t-bom-tridion-9
I got following error, when requesting a page. It seems when component have keyword filed this error occurs. If there is no keyword field in components, DD4T works.
2023-12-01 07:44:52,084 ERROR [ajp-nio-0:0:0:0:0:0:0:1-8009-exec-3] JsonDataBinder - Error deserializing.
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.dd4t.contentmodel.Keyword` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: org.dd4t.contentmodel.impl.ComponentImpl["Fields"]->java.util.LinkedHashMap["backgroundColor"]->org.dd4t.contentmodel.impl.KeywordField["Keywords"]->java.util.ArrayList[0])
I found similar issue on following post, so I added <context:annotation-config/>
to dispatcher-servlet.xml, but the problem was not solved.
DD4T data bind deserialization exception on Page metadata
How can I let DD4T work? Is there any special configuration required?
This error's full stack trace:
2023-12-01 07:44:51,986 DEBUG [ajp-nio-0:0:0:0:0:0:0:1-8009-exec-3] JsonDataBinder - RootElementName is: HomeShortCut
2023-12-01 07:44:52,084 ERROR [ajp-nio-0:0:0:0:0:0:0:1-8009-exec-3] JsonDataBinder - Error deserializing.
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Cannot construct instance of `org.dd4t.contentmodel.Keyword` (no Creators, like default constructor, exist): abstract types either need to be mapped to concrete types, have custom deserializer, or contain additional type information
at [Source: UNKNOWN; byte offset: #UNKNOWN] (through reference chain: org.dd4t.contentmodel.impl.ComponentImpl["Fields"]->java.util.LinkedHashMap["backgroundColor"]->org.dd4t.contentmodel.impl.KeywordField["Keywords"]->java.util.ArrayList[0])
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:67)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadDefinition(DeserializationContext.java:1909)
at com.fasterxml.jackson.databind.DatabindContext.reportBadDefinition(DatabindContext.java:408)
at com.fasterxml.jackson.databind.DeserializationContext.handleMissingInstantiator(DeserializationContext.java:1354)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserialize(AbstractDeserializer.java:274)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
at com.fasterxml.jackson.module.afterburner.deser.SettableObjectMethodProperty.deserializeAndSet(SettableObjectMethodProperty.java:47)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.vanillaDeserialize(BeanDeserializer.java:314)
at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:215)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:120)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:144)
at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:110)
at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:263)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer._readAndBindStringKeyMap(MapDeserializer.java:625)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:449)
at com.fasterxml.jackson.databind.deser.std.MapDeserializer.deserialize(MapDeserializer.java:32)
at com.fasterxml.jackson.module.afterburner.deser.SettableObjectMethodProperty.deserializeAndSet(SettableObjectMethodProperty.java:47)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:278)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4706)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2879)
at org.dd4t.databind.builder.json.JsonDataBinder.buildComponent(JsonDataBinder.java:144)
at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.renderComponentData(ComponentPresentationDeserializer.java:162)
at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.deserialize(ComponentPresentationDeserializer.java:128)
at org.dd4t.databind.serializers.json.ComponentPresentationDeserializer.deserialize(ComponentPresentationDeserializer.java:53)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer._deserializeFromArray(CollectionDeserializer.java:359)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:244)
at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:28)
at com.fasterxml.jackson.module.afterburner.deser.SettableObjectMethodProperty.deserializeAndSet(SettableObjectMethodProperty.java:47)
at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:278)
at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:155)
at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:323)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4730)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3677)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3645)
at org.dd4t.databind.builder.json.JsonDataBinder.buildPage(JsonDataBinder.java:84)
at org.dd4t.core.factories.impl.PageFactoryImpl.deserialize(PageFactoryImpl.java:383)
at org.dd4t.core.factories.impl.PageFactoryImpl.producePage(PageFactoryImpl.java:356)
at org.dd4t.core.factories.impl.PageFactoryImpl.findPageByUrl(PageFactoryImpl.java:330)
at org.dd4t.core.factories.impl.PageFactoryImpl.findPageByUrl(PageFactoryImpl.java:66)
at org.dd4t.springmvc.controller.DynamicPageControllerExtend.handleRequestInternal(DynamicPageControllerExtend.java:116)
at org.springframework.web.servlet.mvc.AbstractController.handleRequest(AbstractController.java:177)
at org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter.handle(SimpleControllerHandlerAdapter.java:51)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:502)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:596)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:209)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at jp.co.okidata.tridion.partner.servlet.filter.LoginFilter.doFilter(LoginFilter.java:286)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:117)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at jp.co.okidata.tridion.dd4t.core.servlet.AbsolutePathFilter.doFilter(AbsolutePathFilter.java:84)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at jp.co.okidata.tridion.inquiry.servlet.MultipartFilter.doFilter(MultipartFilter.java:49)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:178)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:153)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:167)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:90)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:492)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:130)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:93)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:673)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:433)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:63)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:926)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1791)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:833)
My dependency for DD4T in pom.xml:
<dependency>
<groupId>org.dd4t</groupId>
<artifactId>dd4t-core</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.dd4t</groupId>
<artifactId>dd4t-caching</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.dd4t</groupId>
<artifactId>dd4t-providers-common</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.dd4t</groupId>
<artifactId>dd4t-providers-odata</artifactId>
<version>2.1.12</version>
</dependency>
<dependency>
<groupId>org.dd4t</groupId>
<artifactId>dd4t-mvc-support</artifactId>
<version>2.1.12</version>
</dependency>
dispatcher-servlet.xml summary:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
https://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<bean id="modelConverter" class="org.dd4t.databind.builder.json.JsonModelConverter"/>
<bean id="dataBinder" class="org.dd4t.databind.builder.json.JsonDataBinder" init-method="init">
<!-- Set this value to your own models package root -->
<property name="viewModelPackageRoot" value="jp.co.test.tridion.dd4t.model" />
<property name="viewModelMetaKeyName" value="viewName" />
<!-- Set these to your need. If you only want regular Components set to true -->
<property name="renderDefaultComponentModelsOnly" value="false" />
<property name="renderDefaultComponentsIfNoModelFound" value="true"/>
<property name="modelConverter" ref="modelConverter"/>
<!-- override these if you want your own implementations -->
<property name="concreteComponentPresentationImpl" value="org.dd4t.contentmodel.impl.ComponentPresentationImpl"/>
<property name="concreteComponentTemplateImpl" value="org.dd4t.contentmodel.impl.ComponentTemplateImpl"/>
<property name="concreteComponentImpl" value="org.dd4t.contentmodel.impl.ComponentImpl"/>
<property name="concreteFieldImpl" value="org.dd4t.contentmodel.impl.BaseField"/>
</bean>
<!-- DD4T factories entry point -->
<bean id="databindFactory" class="org.dd4t.databind.DataBindFactory" factory-method="createInstance">
<constructor-arg ref="dataBinder"/>
</bean>
Regards,