Is it required to update AEM as a Cloud Version JDK(Java) when the build encounters a Java mismatch?
We had a requirement to use `com.adobe.cq.wcm.spi.AssetDelivery`, and the team proceeded to update the AEM SDK API version to a newer version, as shown below.
This resulted in a build error in AEM cloud pipeline.
06:29:00,564 [ThreadedStreamConsumer] [ERROR] testExportedType Time elapsed: 0.001 s <<< ERROR!
java.lang.RuntimeException: Unable to initialize JCR_MOCK resource resolver factory: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.MockJcrSlingRepository
Caused by: java.lang.RuntimeException: Unable to invoke method 'activate' for class org.apache.sling.testing.mock.sling.MockJcrSlingRepository
Caused by: java.lang.UnsupportedClassVersionError: org/apache/jackrabbit/api/observation/JackrabbitObservationManager has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
JDK Versions
As we are aware,
Class file Version 52.0 uses java JDK 8 &
Class file Version 55.0, uses java JDK 11
The AEM Cloud JDK is set to version 8 by default, but it can be upgraded to version 11.
Whenever a Java compiler mismatch occurs in cloud pipeline, people are often tempted to upgrade the AEM Cloud JDK version.
But we went ahead and explored the AssetDelivery Interface and realized this class was introduced to AEM SDK API in 2022 May itself. See reference url.
So we have updated the aem.sdk.api to use the earlier version rather than the latest in our pom file.
This resolved our build error, and the functionality related to the AssetDelivery class started working as expected.
Side effects:
It is always recommended to use the latest version of API packages, as they may include enhanced security features. However, when upgrading the JDK, extensive application testing is required. Additionally, there may be project-specific reasons to upgrade the JDK in phases rather than all at once.
If there were an official Adobe document outlining the JDK version compatibility between AEM SDK API and Java versions, it would have made decision-making much faster. Unfortunately, I couldn't find such a document, nor is the information available in the software distribution portal. If anyone knows of it, please share the URL in the comments section.
How do we update JDK version in AEM as Cloud?
- By default, the JAVA_HOME environment variable is set to /usr/lib/jvm/jdk1.8.0_401, which contains Oracle JDK 8u401. This default should be overridden for AEM Cloud Projects to use JDK 11.
- See the Setting the Maven JDK Version section for more details.
No comments:
Post a Comment