Closed HENgames closed 8 months ago
Basically AEMs WCMUsePojo uses the legacy aQute.bnd.annotation.ConsumerType
. It is not clear why the error is only triggered when ACS AEM Commons is on the classpath as well as in your example project nothing is referenced from there.
Also executing javac with verbose settings exposes
INFO] --- compiler:3.11.0:compile (default-compile) @ acscommonsprob-reproducer ---
[INFO] Changes detected - recompiling the module! :source
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file with javac [debug verbose target 1.8] to target/classes
[parsing started SimpleFileObject[/Users/konradwindszus/git/acscommonsprob/src/main/java/Reproducer.java]]
[parsing completed 7ms]
[search path for source files: /Users/konradwindszus/git/acscommonsprob/src/main/java,/Users/konradwindszus/git/acscommonsprob/target/generated-sources/annotations]
[search path for class files: /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/lib/modules,/Users/konradwindszus/git/acscommonsprob/target/classes,/Users/konradwindszus/.m2/repository/com/adobe/acs/acs-aem-commons-bundle/6.3.2/acs-aem-commons-bundle-6.3.2.jar,/Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar,.]
[loading /Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar(/com/adobe/cq/sightly/WCMUsePojo.class)]
[loading /Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar(/org/apache/sling/scripting/sightly/pojo/Use.class)]
[loading /modules/java.base/java/lang/Object.class]
[loading /modules/java.base/java/lang/Deprecated.class]
[loading /modules/java.base/java/lang/Override.class]
[loading /modules/java.base/java/lang/annotation/Annotation.class]
[loading /modules/java.base/java/lang/annotation/Retention.class]
[loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
[loading /modules/java.base/java/lang/annotation/Target.class]
[loading /modules/java.base/java/lang/annotation/ElementType.class]
[checking Reproducer]
[loading /modules/java.base/java/io/Serializable.class]
[loading /modules/java.base/java/lang/Exception.class]
[loading /modules/java.base/java/lang/AutoCloseable.class]
[total 173ms]
[INFO] -------------------------------------------------------------
[WARNING] COMPILATION WARNING :
[INFO] -------------------------------------------------------------
[WARNING] bootstrap class path not set in conjunction with -source 8
[INFO] 1 warning
[INFO] -------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] cannot access aQute.bnd.annotation.ConsumerType
class file for aQute.bnd.annotation.ConsumerType not found
[INFO] 1 error
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.576 s
[INFO] Finished at: 2023-11-30T16:48:42+01:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.11.0:compile (default-compile) on project acscommonsprob-reproducer: Compilation failure
[ERROR] cannot access aQute.bnd.annotation.ConsumerType
[ERROR] class file for aQute.bnd.annotation.ConsumerType not found
[ERROR]
[ERROR] -> [Help 1]
(ACS AEM Commons 6.3.2)
vs
INFO] --- compiler:3.11.0:compile (default-compile) @ acscommonsprob-reproducer ---
[INFO] Changes detected - recompiling the module! :source
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file with javac [debug verbose target 1.8] to target/classes
[parsing started SimpleFileObject[/Users/konradwindszus/git/acscommonsprob/src/main/java/Reproducer.java]]
[parsing completed 7ms]
[search path for source files: /Users/konradwindszus/git/acscommonsprob/src/main/java,/Users/konradwindszus/git/acscommonsprob/target/generated-sources/annotations]
[search path for class files: /Library/Java/JavaVirtualMachines/temurin-11.jdk/Contents/Home/lib/modules,/Users/konradwindszus/git/acscommonsprob/target/classes,/Users/konradwindszus/.m2/repository/com/adobe/acs/acs-aem-commons-bundle/4.7.0/acs-aem-commons-bundle-4.7.0.jar,/Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar,.]
[loading /Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar(/com/adobe/cq/sightly/WCMUsePojo.class)]
[loading /Users/konradwindszus/.m2/repository/com/adobe/aem/uber-jar/6.5.17/uber-jar-6.5.17.jar(/org/apache/sling/scripting/sightly/pojo/Use.class)]
[loading /modules/java.base/java/lang/Object.class]
[loading /modules/java.base/java/lang/Deprecated.class]
[loading /modules/java.base/java/lang/Override.class]
[loading /modules/java.base/java/lang/annotation/Annotation.class]
[loading /modules/java.base/java/lang/annotation/Retention.class]
[loading /modules/java.base/java/lang/annotation/RetentionPolicy.class]
[loading /modules/java.base/java/lang/annotation/Target.class]
[loading /modules/java.base/java/lang/annotation/ElementType.class]
[checking Reproducer]
[loading /modules/java.base/java/io/Serializable.class]
[loading /modules/java.base/java/lang/Exception.class]
[loading /modules/java.base/java/lang/AutoCloseable.class]
[wrote /Users/konradwindszus/git/acscommonsprob/target/classes/Reproducer.class]
[total 179ms]
[WARNING] bootstrap class path not set in conjunction with -source 8
[INFO] ------------------------------------------------------------------------
(with ACS AEM Commons 4.7.0)
It works once you disable annotation processing with the javac option -proc:none
(https://docs.oracle.com/en/java/javase/17/docs/specs/man/javac.html#annotation-processing).
It is a regression introduced with https://github.com/Adobe-Consulting-Services/acs-aem-commons/blob/master/bundle/src/main/java/com/adobe/acs/commons/mcp/form/DialogProviderAnnotationProcessor.java. introduced with #2317. Not sure why this triggers the loading of this legacy annotation class though. @badvision Any idea?
I can confirm that your fix solves our problem while testing with acs-aem-commons-bundle version 6.3.4. Thanks for your effort, @kwin !
Required Information
Expected Behavior
I uploaded a simple maven testproject to
https://github.com/HENgames/acscommonsprob
The only class extends com.adobe.cq.sightly.WCMUsePojo, the only dependencies are uber-jar 6.5.17 and acs-aem-commons-bundle 6.3.2. The maven build should finish without any problem.
Actual Behavior
I get the following errors on mvn clean install:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project acscommonsprob-reproducer: Compilation failure [ERROR] cannot access aQute.bnd.annotation.ConsumerType [ERROR] class file for aQute.bnd.annotation.ConsumerType not found
Steps to Reproduce
Run
mvn clean install
on the mentioned project. You should get the messages stated above. When downgrading acs-aem-commons-bundle to 4.7.0 or lower, the maven build finishes without any error.
My current configuration is:
mvn -v Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: [..] Java version: 1.8.0_392, vendor: Azul Systems, Inc., runtime: [..] Default locale: de_DE, platform encoding: UTF-8 OS name: "mac os x", version: "13.6.2", arch: "aarch64", family: "mac"
We have several different build systems, all with the same problem.
Links
I have seen this problem mentioned in other places, like
https://sourcedcode.com/blog/aem/aem-project-wcmusepojo-class-error-of-class-file-for-aqute-bnd-annotation-consumertype-not-found
https://github.com/projectlombok/lombok/issues/2145
The common advice is to include dependency
This is no solution in our case, as the dependency is from 2014 and contains older versions of the official OSGi annotations (<= 5.0 it seems). I have found out, that including the following dependency solves the problem:
I have seen the newer version 7.0.0, but for now we are bound to 6.4.1 as the newest java 8 compatible version.
Can you recommend this solution / workaround?