Error message "Cannot get DefaultSlingScript: Compilation errors in... cannot be resolved to a type" while creating a new component for the WKND tutorial
I have created a new component for the WKND tutorial project. Its html file has the following code:
I have created an interface com.adobe.aem.guides.wknd.core.models.components.ContentFragmentByURL.java that extends the interface ComponentExporter.
I have also created an implementation of my interface in com.adobe.aem.guides.wknd.core.models.components.impl.ContentFragmentByURLImpl.java
...
@Model(
adaptables = {SlingHttpServletRequest.class},
adapters = {ContentFragmentByURL.class, ComponentExporter.class},
resourceType = {ContentFragmentByURLImpl.RESOURCE_TYPE},
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
@Exporter(name = ExporterConstants.SLING_MODEL_EXPORTER_NAME, extensions = ExporterConstants.SLING_MODEL_EXTENSION)
public class ContentFragmentByURLImpl implements ContentFragmentByURL{
protected static final String RESOURCE_TYPE = "wknd/components/contentfragmentbyurl";
...
I have created a package-info.java inside com.adobe.aem.guides.wknd.core.models.components.
I can generate the project and I can deploy it into a local AEM 6.5 instance.
If I go to http://localhost:4502/system/console/bundles I can see that my bundle "WKND Sites Project - Core (aem-guides-wknd.core)" is active.
If I go to http://localhost:4502/system/console/adapters I can see my adapters listed but the interface and its implementation appear in red color:
com.adobe.aem.guides.wknd.core.models.components.ContentFragmentByURL
com.adobe.cq.export.json.ComponentExporter
com.adobe.aem.guides.wknd.core.models.components.impl.ContentFragmentByURLImpl
If I compare it with the Byline example from the WKND tutorial, the interfacte Byline.java does not appear in red color:
com.adobe.aem.guides.wknd.core.models.Byline
com.adobe.aem.guides.wknd.core.models.impl.BylineImpl
If I go to http://localhost:4502/system/console/status-adapters I can see the interface and its implementation listed:
Adaptable: org.apache.sling.api.SlingHttpServletRequest Providing Bundle: org.apache.sling.models.impl Available Adapters: * com.adobe.aem.guides.wknd.core.models.components.ContentFragmentByURL * com.adobe.cq.export.json.ComponentExporter * com.adobe.aem.guides.wknd.core.models.components.impl.ContentFragmentByURLImpl
If I create a page and add my component, I get the following error:
31.10.2022 13:35:07.189 *ERROR* [127.0.0.1 [1667219707133] GET /content/wknd/language-masters/en/detalle-de-fragmento-de-contenido-04/jcr:content/root/container/contentfragmentbyurl.html HTTP/1.1] com.day.cq.wcm.core.impl.WCMDebugFilter Error during include of SlingRequestPathInfo: path='/content/wknd/language-masters/en/detalle-de-fragmento-de-contenido-04/jcr:content/root/container/contentfragmentbyurl', selectorString='null', extension='html', suffix='null'
org.apache.sling.api.SlingException: Cannot get DefaultSlingScript: Compilation errors in org/apache/sling/scripting/sightly/apps/wknd/components/contentfragmentbyurl/contentfragmentbyurl_html.java:
Line 43, column 1927 : com.adobe.aem.guides.wknd.core.models.components.ContentFragmentByURL cannot be resolved to a type
at ...
Caused by: org.apache.sling.scripting.sightly.SightlyException: Compilation errors in org/apache/sling/scripting/sightly/apps/wknd/components/contentfragmentbyurl/contentfragmentbyurl_html.java:
Line 43, column 1927 : com.adobe.aem.guides.wknd.core.models.components.ContentFragmentByURL cannot be resolved to a type
at ... 141 common frames omitted
Can anybody, please, spot what I am missing?
Thanks in advance.