Skip to content

Form core components breaks AEM core components implementation #817

Open
@koffieislekker

Description

I have an AEM project that already installs the aem core components (2.22.12). I am not sure why the forms core components also embedds the aem core components (which I think causes the issue) since this can be installed/seperatly in your project pom.xml

Expected Behaviour

When trying to extend the AEM core components I expect the core component to be able to be injected properly.

Actual Behaviour

When installing the forms core component the aem sites project that extend an AEM core component breaks.

Reproduce Scenario (including but not limited to)

Adding a simple List implementation java class that injects the Core components List component breaks the component.

Steps to Reproduce

  1. Create a project
    mvn -B org.apache.maven.plugins:maven-archetype-plugin:3.2.1:generate -D archetypeGroupId=com.adobe.aem -D archetypeArtifactId=aem-project-archetype -D archetypeVersion=43 -D appTitle="My Site" -D appId="mysite" -D groupId="com.mysite" -D aemVersion=6.5.17 -D includeExamples=y -D includeFormscommunications=y -D includeFormsenrollment=y

  2. Create a simple List class (Could be any core component class)

  3. Go to the generated en.html (project must be built first) and add the List component to the page.

Platform and Version

Windows 11
Java 11.0.19

AEM Version (mention the exact version in case of cloud SDK)

AEM 6.5.17

AEM Forms Version

adobe-aemfd-win-pkg-6.0.968

Sample Code that illustrates the problem

package com.mysite.core.models;

@model(adaptables = SlingHttpServletRequest.class, adapters = {List.class}, resourceType =
MyCustomListImpl.RESOURCE_TYPE)
public class MyCustomListImpl implements List {

protected static final String RESOURCE_TYPE = "mysite/components/list";

@Self
@Via(type = ResourceSuperType.class)
private List list;

@Override
public Collection<ListItem> getListItems() {
    return list.getListItems();
}

}

Logs taken while reproducing problem

Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.mysite.core.models.MyCustomListImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:754) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:428) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.createModel(ModelAdapterFactory.java:282) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.scripting.sightly.models.impl.SlingModelsUseProvider.provide(SlingModelsUseProvider.java:126) [org.apache.sling.scripting.sightly.models.provider:1.0.8]
at org.apache.sling.scripting.sightly.impl.engine.extension.use.UseRuntimeExtension.call(UseRuntimeExtension.java:72) [org.apache.sling.scripting.sightly:1.1.2.1_4_0]
... 441 common frames omitted
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject private com.adobe.cq.wcm.core.components.models.List com.mysite.core.models.MyCustomListImpl.list
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:738) [org.apache.sling.models.impl:1.4.16.B0002]
... 445 common frames omitted
Caused by: org.apache.sling.models.factory.ModelClassException: Could not create model from class org.apache.sling.models.impl.via.AbstractResourceTypeViaProvider$ResourceTypeForcingRequestWrapper: Could not inject all required fields into class com.mysite.core.models.MyCustomListImpl
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1059) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1034) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:977) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:115) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:475) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:575) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:733) [org.apache.sling.models.impl:1.4.16.B0002]
... 445 common frames omitted
Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.mysite.core.models.MyCustomListImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:754) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:428) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1053) [org.apache.sling.models.impl:1.4.16.B0002]
... 451 common frames omitted
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject private com.adobe.cq.wcm.core.components.models.List com.mysite.core.models.MyCustomListImpl.list
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:738) [org.apache.sling.models.impl:1.4.16.B0002]
... 453 common frames omitted
Caused by: org.apache.sling.models.factory.ModelClassException: Could not create model from class org.apache.sling.models.impl.via.AbstractResourceTypeViaProvider$ResourceTypeForcingRequestWrapper: Could not inject all required fields into class com.mysite.core.models.MyCustomListImpl
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1059) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.adaptIfNecessary(ModelAdapterFactory.java:1034) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.setField(ModelAdapterFactory.java:977) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.access$200(ModelAdapterFactory.java:115) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory$SetFieldCallback.inject(ModelAdapterFactory.java:475) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:575) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:733) [org.apache.sling.models.impl:1.4.16.B0002]
... 453 common frames omitted
Caused by: org.apache.sling.models.factory.MissingElementsException: Could not inject all required fields into class com.mysite.core.models.MyCustomListImpl
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:754) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.internalCreateModel(ModelAdapterFactory.java:428) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.adapt(ModelAdapterFactory.java:1053) [org.apache.sling.models.impl:1.4.16.B0002]
... 459 common frames omitted
Suppressed: org.apache.sling.models.factory.MissingElementException: Could not inject private com.adobe.cq.wcm.core.components.models.List com.mysite.core.models.MyCustomListImpl.list
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:738) [org.apache.sling.models.impl:1.4.16.B0002]
... 461 common frames omitted
Caused by: org.apache.sling.models.factory.ModelClassException: No injector returned a non-null value!
at org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:615) [org.apache.sling.models.impl:1.4.16.B0002]
at org.apache.sling.models.impl.ModelAdapterFactory.createObject(ModelAdapterFactory.java:733) [org.apache.sling.models.impl:1.4.16.B0002]
... 461 common frames omitted

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions