adobe / aem-guides-wknd

Tutorial Code companion for Getting Started Developing with AEM Sites WKND Tutorial
https://experienceleague.adobe.com/docs/experience-manager-learn/getting-started-wknd-tutorial-develop/overview.html
MIT License
288 stars 569 forks source link

Byline component build failure #72

Closed NotWiggo closed 4 years ago

NotWiggo commented 4 years ago

AEM 6.5, everything else apparently up to date.

I've been trying to build the custom Byline component (though to be perverse, mine is called 'Intro') and I am getting compile errors as shown:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.1:compile (default-compile) on project aem-demos-gl_demo.core: Compilation failure: Compilation failure: [ERROR] /D:/AEM65/src/aem-demos-gl_demo/core/src/main/java/com/gw/aem/demos/gl_demo/core/models/impl/IntroImpl.java:[34,51] package com.adobe.cq.wcm.core.components.models does not exist [ERROR] /D:/AEM65/src/aem-demos-gl_demo/core/src/main/java/com/gw/aem/demos/gl_demo/core/models/impl/IntroImpl.java:[57,17] cannot find symbol [ERROR] symbol: class Image [ERROR] location: class com.gw.aem.demos.gl_demo.core.models.impl.IntroImpl [ERROR] /D:/AEM65/src/aem-demos-gl_demo/core/src/main/java/com/gw/aem/demos/gl_demo/core/models/impl/IntroImpl.java:[98,17] cannot find symbol [ERROR] symbol: class Image [ERROR] location: class com.gw.aem.demos.gl_demo.core.models.impl.IntroImpl [ERROR] /D:/AEM65/src/aem-demos-gl_demo/core/src/main/java/com/gw/aem/demos/gl_demo/core/models/impl/IntroImpl.java:[61,93] cannot find symbol [ERROR] symbol: class Image [ERROR] location: class com.gw.aem.demos.gl_demo.core.models.impl.IntroImpl [ERROR] /D:/AEM65/src/aem-demos-gl_demo/core/src/main/java/com/gw/aem/demos/gl_demo/core/models/impl/IntroImpl.java:[81,19] cannot find symbol [ERROR] symbol: class Image [ERROR] location: class com.gw.aem.demos.gl_demo.core.models.impl.IntroImpl [ERROR] -> [Help 1]

I'm very new to this stuff, but the Eclipse editor seems happy that everything resolves correctly in the IntroImpl.java code:

` package com.gw.aem.demos.gl_demo.core.models.impl;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import javax.annotation.PostConstruct;

import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.models.annotations.DefaultInjectionStrategy;
import org.apache.sling.models.annotations.Model;
import org.apache.sling.models.annotations.injectorspecific.OSGiService;
import org.apache.sling.models.annotations.injectorspecific.Self;
import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
import org.apache.sling.models.factory.ModelFactory;

import com.gw.aem.demos.gl_demo.core.models.Intro;
import com.adobe.cq.wcm.core.components.models.Image;

@Model(
        adaptables = {SlingHttpServletRequest.class},
        adapters = {Intro.class},
        resourceType = {IntroImpl.RESOURCE_TYPE},
        defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL
)
public class IntroImpl implements Intro {
    protected static final String RESOURCE_TYPE = "gl_demo/components/content/intro";

etc etc`

The Build Path in Eclipse references core.wcm.components.core-2.7.0.jar in the .m2 repository, so at this point, I'm stumped. Any clues where to start looking? I've run mvn -PautoInstallBundle clean install, and started and stopped the server (why, I have no idea, it won't compile, never mind deploy) all to no avail...

godanny86 commented 4 years ago

Hi @NotWiggo can you verify that the Core Component bundle is included in the core/pom.xml?

https://github.com/adobe/aem-guides-wknd/blob/custom-component/solution/core/pom.xml#L97

NotWiggo commented 4 years ago

OK, thanks, that worked. There was no com.adobe.cq dependency in the POM. Now, is that a problem with archetype 22, with the tutorial text or just a stupid schoolboy error on my part? ;-)

godanny86 commented 4 years ago

Its a problem on our end :)

Thank you @NotWiggo for filing, this will help us improve :)

marcelomg commented 1 year ago

Hi, this issue is still happening. I could verify that the core component is present in the core/pom.xml. I was able to get pass it by running: mvn clean install -PautoInstallSinglePackage -Pclassic

Bronson-Akcelo commented 1 year ago

Hey folks, I had a similar issue while I was working through the tutorial so I thought I might post it for others or in case someone wants to update the docs. After following through the tutorial I was seeing:

Compilation failure
[ERROR] /Volumes/Sites/wknd-tutorial/ui.apps/target/generated-sources/htl/org/apache/sling/scripting/sightly/apps/wknd/components/byline/byline__002e__html.java:[41,81] cannot find symbol
[ERROR]   symbol:   class Byline
[ERROR]   location: package com.adobe.aem.guides.wknd.core.models

To get around this I had to run the commands in the opposite order for it to work for AEM Cloud. So instead of:

$ cd aem-guides-wknd/ui.apps
$ mvn clean install -PautoInstallPackage

then

$ cd ../core
$ mvn clean install -PautoInstallBundle

I did core first then ui.apps second. i.e

$ cd ../core
$ mvn clean install -PautoInstallBundle

then

$ cd aem-guides-wknd/ui.apps
$ mvn clean install -PautoInstallPackage

Then everything built successfully.