Expand my Community achievements bar.

SOLVED

com.adobe.cq.wcm.core.components.internal -- Cannot be resolved

Avatar

Level 6

We are trying to copy the entire class over into our code base, the https://github.com/adobe/aem-core-wcm-components/blob/d3d89a177d9a5095a648484a1b00d2046e73ce27/bundl..., but when we are trying to push the new bundle into AEM, we get 3 errors in the bundle in system console

 

com.adobe.cq.wcm.core.components.internal -- Cannot be resolved
com.adobe.cq.wcm.core.components.internal.link -- Cannot be resolved
com.adobe.cq.wcm.core.components.internal.models.v1 -- Cannot be resolved

 

We have added this dependency in the core

<dependency>
<groupId>com.adobe.cq</groupId>
<artifactId>core.wcm.components.core</artifactId>
<version>2.16.4</version>
<scope>compile</scope>
</dependency>

But it is not working as expected.

 

How do we actually import and compile the adobe library?

 

https://github.com/adobe/aem-core-wcm-components/blob/d3d89a177d9a5095a648484a1b00d2046e73ce27/bundl...

...
import org.jetbrains.annotations.Nullable;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;

import com.adobe.cq.wcm.core.components.internal.LocalizationUtils;
import com.adobe.cq.wcm.core.components.commons.link.LinkManager;
import com.adobe.cq.wcm.core.components.internal.models.v1.PageListItemImpl;
import com.adobe.cq.wcm.core.components.internal.models.v1.SearchImpl;
...

Please let me know how we can resolve this.

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @AEMWizard,

This is expected, and it's aligned how Core Components has been designed.

In general all models/classes located under internal package are not exported by Core Components bundles. This means you cannot use them directly (despite the fact that you can do it on your IDE), this is done by design.

In other words the way how you implementation is done is incorrect, this is why the issue occurs.

The proper way to extend Core Components model is to use delegation pattern. Here you can find some information with examples:

And some code example:

@Model(adaptables = SlingHttpServletRequest.class,
       adapters = List.class,
       resourceType = "myproject/components/list")
public class ListImpl implements List {

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

    /** 
    * using original implementation
    */
    @Override 
    public String getDateFormatString() {
        // place for custom implementation that will be different comparing to orignal one
    }


    /** 
    * using original implementation
    */
    @Override
    public boolean linkItems() {
        // simply run method from Core Components List implementation
        return list.linkItems();
    }

    // place for other methods from List interface
}

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

Hi @AEMWizard,

This is expected, and it's aligned how Core Components has been designed.

In general all models/classes located under internal package are not exported by Core Components bundles. This means you cannot use them directly (despite the fact that you can do it on your IDE), this is done by design.

In other words the way how you implementation is done is incorrect, this is why the issue occurs.

The proper way to extend Core Components model is to use delegation pattern. Here you can find some information with examples:

And some code example:

@Model(adaptables = SlingHttpServletRequest.class,
       adapters = List.class,
       resourceType = "myproject/components/list")
public class ListImpl implements List {

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

    /** 
    * using original implementation
    */
    @Override 
    public String getDateFormatString() {
        // place for custom implementation that will be different comparing to orignal one
    }


    /** 
    * using original implementation
    */
    @Override
    public boolean linkItems() {
        // simply run method from Core Components List implementation
        return list.linkItems();
    }

    // place for other methods from List interface
}