Welcome to Tech Mastery, your expert source for insights into technology and digital strategy. Explore topics like Adobe Experience Manager, AWS, Azure, generative AI, and advanced marketing strategies. Delve into MACH architecture, Jamstack, modern software practices, DevOps, and SEO. Our blog is ideal for tech professionals and enthusiasts eager to stay ahead in digital innovations, from Content Management to Digital Asset Management and beyond.
I configured the AEM-Adobe Target integration by enabling:
IMS configuration for authentication
Legacy Adobe Target Cloud Config and New Adobe Target Cloud Config
Default workspace assignment in Adobe Developer Console Project
Approver permissions for the API credential in the Admin Console
However, when attempting to create an A/B test or Experience Targeting (XT) activity from AEM and sync it to Adobe Target, the Target Configuration dropdown was empty, indicating that no configurations were detected.
Root Cause & Resolution
Upon further analysis, I identified that the issue was due to the user not being part of the target-activity-authors group. After adding the user to this group, the activity creation process began recognizing all available Adobe Target configurations, including both legacy and new configurations.
Now, activities can be successfully created and synced to the default workspace once the experience is defined.
Sling Models are annotation-driven Java "POJO's" (Plain Old Java Objects) that facilitate the mapping of data from the JCR to Java variables and provide several other niceties when developing in the context of AEM. When you adapt to a sling model, the model factory returns the specific model implementation; the returned model implementation is selected through the model pickers.
In this post, let us dive deep into how this model picking works internally.
The Sling Model Framework has the Implementation Picker to select the specific model implementation.
The Implementation Picker interface can be referred to here — ImplementationPicker (Apache Sling 8 API); the picker interface is enabled with a picker method responsible for selecting a specific model implementation.
The Sling Framework, by default, has the below picker implementations.
First Implementation Picker:
This is the default picker implementation; it picks the first implementation from the list alphabetically ordered by class name. If there are multiple implementations of the specific models, this one selects the first one and returns it to the requestor. First Implementation Picker will be used if no other implementations support picking the model implementation.
The service ranking is set to the highest (Integer.MAX_VALUE) to support more custom picker implementations.
All the core components reference the model interface directly — com.adobe.cq.wcm.core.components.models.Carousel; the model implementations are always enabled with a specific version, so the Resource Type Based Resource Picker will not pick any model implementation, and the picking is delegated to the Latest VersionImplementation Picker, and this always returns the latest model implementation based on the version number — e.g.,com.adobe.cq.wcm.core.components.internal.models.v1.CarouselImpl).
The External models that implement Core Component interfaces have precedence over internal models, allowing us to enable model delegation for the core components.
The custom picker implementation can be enabled by implementing the org.apache.sling.models.spi.ImplementationPicker interface and picker method with your custom model picker logic; the ranking should be enabled accordingly to ensure the default implementations are not impacted.
java.lang.ClassCastException for the same class com.sample.test.Test cannot be cast to com.sample.test.Test - Adobe Experience Manager(AEM)
We were facing a strange ClassCastException - ClassCastException pointing to the same class in Adobe Experience Manager(AEM)
java.lang.ClassCastException: com.sample.test.Test cannot be cast to com.sample.test.Test
While analyzing through depfinder - http://localhost:4502/system/console/depfinder, there is two version of the same class available from two different packages.
But this class is only defined in one of the package and referred in the other package, after analyzing the Sling class loading is little different - If one of the class com.sample.test.Test is referred from different package, Sling copies the classes locally to the target package and if the target package export the same package(<Export-Package>) - com.sample.* then Sling export the classes copied from other package that matches the export pattern, in this case our target package is already exporting com.sample.* so two version of same class is available now. This will lead to the ClassCastException specified above.
To fix this issue, we can change the target package pom.xml file to restrict the export of referred classes from other package.