Java dependency on assetshare.core w/ Uber-jar 6.5.9 leads to java.lang.ClassNotFoundException
Describe the bug We are in the process of upgrading from AEM 6.5.6 and ASC 1.9.4 to AEM 6.5.9 and ASC 2.0.6. When we update all the appropriate includes and dependencies within our pom files, and run a maven build, our unit tests fail with errors like:
[ERROR] <testName> Time elapsed: 0.001 s <<< ERROR!
java.lang.NoClassDefFoundError: com/adobe/cq/dam/download/api/DownloadException
Caused by: java.lang.ClassNotFoundException: com.adobe.cq.dam.download.api.DownloadException
What appears to be to be happening is that because ASC is compiled only against the CS SDK, there is some sort of transitive dependency there that isn't included in the uber jar. I tried a few different exclusions on our dependency on the asset share.core, all to no avail. I tried both of the following:
<dependency>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare.core</artifactId>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-sdk-api</artifactId>
</exclusion>
</exclusions>
</dependency>
and
<dependency>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare.core</artifactId>
<type>jar</type>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
What eventually did seem to work for me is to include a dependency on the AEM SDK, with the scope set to test, such as:
<dependency>
<groupId>com.adobe.aem.commons</groupId>
<artifactId>assetshare.core</artifactId>
<type>jar</type>
</dependency>
<dependency>
<groupId>com.adobe.aem</groupId>
<artifactId>aem-sdk-api</artifactId>
<version>2021.3.4997.20210303T022849Z-210225</version>
<scope>test</scope>
</dependency>
But that seems like a hack that may have other ramifications. Ideally, there is way to have a dependency on ASC.core v.2.x for 6.5.x without these types of issues.
Environment
- AEM Version: 6.5.9
- Asset Share Commons Version: 2.0.6
- Author, Publish or both: n/a
mmm - Interesting. Can I ask what your test is doing? (i assume it uses some ASC API? which one?)
Actually no. The test doesn't touch any ASC code at all. This error happens for all of the unit tests in our core bundle, regardless of what apis they use.
@shsteimer Did you solve this issue, if yes please share the fix details here
Same issue for me with SP 12 (uber-jar 6.5.12). version 1.9.4 works but 2.* always lead to ClassNotFound for DownloadException
when I add the sdk dependency it works for me as well. but that is for sure not a good solution to have it loaded
This should be solved by #754