Hi,
In what scenarios below code can inject TemplatedResourceImpl Instead of JcrNodeResouce Object
@inject
protected Resource resource;
we have upgraded from AEM 6.4 to 6.5 latest SP and seeing this kind of issue.
Thanks,
Venkat
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @venkiiitk,
TemplatedResourceImpl is generally injected when a resource is resolved in the context of editable templates. If the resource being requested is wrapped due to editable template logic, AEM may adapt it to TemplatedResourceImpl.
I tested it on my page created by Editable Template (/conf/myproject/settings/wcm/templates/blank-page/structure/jcr:content/root/container). Below you can find my editable template as example and screenshot from the debugger:
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:template="/conf/myproject/settings/wcm/templates/content-page"
jcr:primaryType="cq:PageContent"
sling:resourceType="myproject/components/page">
<root
jcr:primaryType="nt:unstructured"
sling:resourceType="myproject/components/container"
layout="responsiveGrid">
<container
jcr:primaryType="nt:unstructured"
sling:resourceType="myproject/components/container"
editable="{Boolean}true"
layout="responsiveGrid"/>
</root>
</jcr:content>
</jcr:root>
Here you can see a proof:
Best regards,
Kostiantyn Diachenko.
Views
Replies
Total Likes
Hi konstantyn_diachenko,
Thanks for the reply and interesting.
Let me explain our issue little bit more detailed.
we are using same template and same Core Image component before and after upgrade from 6.4 to 6.5.
In 6.4, Resource resolving to JcrNodeResouce and in 6.5 Resolving to TemplatedResource and in AEM core image component we have some logic like this :
Resource file = resource.getChild(DownloadResource.NN_FILE);
if (file != null) {
mimeType = PropertiesUtil.toString(file.getResourceMetadata().get(ResourceMetadata.CONTENT_TYPE), MIME_TYPE_IMAGE_JPEG);
hasContent = true;
}
So that means, it should fail in both versions and also another observation is , when i verify same in New 6.5 instance then again getting JcrNodeResouce when i use image component under we retail Men pag.
So not sure what happened as part of In-place upgrade.
Thanks,
Venkat
Views
Replies
Total Likes
Hi @venkiiitk,
Could you please provide more details about your editable template structure and content structure?
Best regards,
Kostiantyn Diachenko.
Views
Replies
Total Likes
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
jcr:primaryType="cq:Page">
<jcr:content
cq:deviceGroups="[mobile/groups/responsive]"
cq:lastModified="{Date}2016-09-20T23:10:00.086+02:00"
cq:lastModifiedBy="admin"
cq:template="/conf/we-retail/settings/wcm/templates/content-page"
jcr:primaryType="cq:PageContent"
sling:resourceType="weretail/components/structure/page">
<root
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid">
<header
jcr:created="{Date}2016-09-20T20:34:48.790+02:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2016-09-20T20:34:48.790+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/header">
<navigation
jcr:created="{Date}2018-01-29T11:12:04.131+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-01-29T11:12:44.193+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/navigation"
collectAllPages="false"
navigationRoot="/content/we-retail/language-masters/en"
skipNavigationRoot="true"
structureDepth="2"/>
<languagenavigation
jcr:lastModified="{Date}2018-01-26T15:53:18.689+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/languagenavigation"
navigationRoot="/content/we-retail"
structureDepth="2"/>
<search
jcr:lastModified="{Date}2018-01-26T15:53:18.689+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/search"
searchRoot="/content/we-retail/language-masters/en"/>
</header>
<responsivegrid
jcr:created="{Date}2016-09-20T20:35:34.244+02:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2016-09-20T20:35:34.244+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="wcm/foundation/components/responsivegrid"
editable="{Boolean}true">
<cq:responsive jcr:primaryType="nt:unstructured"/>
</responsivegrid>
<footer
jcr:created="{Date}2016-09-20T20:35:44.080+02:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2016-09-20T20:35:44.080+02:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/footer">
<navigation
jcr:created="{Date}2018-01-29T11:12:04.131+01:00"
jcr:createdBy="admin"
jcr:lastModified="{Date}2018-01-29T11:12:44.193+01:00"
jcr:lastModifiedBy="admin"
jcr:primaryType="nt:unstructured"
sling:resourceType="weretail/components/structure/navigation"
collectAllPages="false"
navigationRoot="/content/we-retail/language-masters/en"
skipNavigationRoot="true"
structureDepth="1"/>
</footer>
</root>
<cq:responsive jcr:primaryType="nt:unstructured">
<breakpoints jcr:primaryType="nt:unstructured">
<phone
jcr:primaryType="nt:unstructured"
title="Smaller Screen"
width="{Long}650"/>
<tablet
jcr:primaryType="nt:unstructured"
title="Tablet"
width="{Long}1200"/>
</breakpoints>
</cq:responsive>
</jcr:content>
</jcr:root>
Views
Replies
Total Likes
Okay, this image resource is not a part of structure. What core components version do you use? How do you use your Sling model or is it Core Component Model? What is the path to image resource?
Views
Replies
Total Likes
Hi,
it is AEM core Image V2 component and version is 2.2.2
and image path like this : /content/we-retail/us/en/demo/jcr:content/root/responsivegrid/image/file/jcr:content
Attached like image file and it is trying to resolve extension and due to TemplatedResource , it is returning default JPEG extension.
Thanks,
Venkat
Views
Replies
Total Likes
Hi,
I see that 2.2.2 version of Core Components is not compatible with AEM 6.5: https://github.com/adobe/aem-core-wcm-components/blob/main/VERSIONS.md Could you please try to install latest compatible version on Core Components and test with it?
I tried to put image in the same location for page created with an editable template. ImageImpl model injected TemplatedResource as well and rendered image with correct extension. I think you need to update Core Components version according to your AEM version.
Best regards,
Kostiantyn Diachenko.
Views
Replies
Total Likes
Views
Likes
Replies