[BUILD] Running maven build command(s)
Using Java version 21 from .cloudmanager/java-version.
Executing command mvn --batch-mode org.apache.maven.plugins:maven-dependency-plugin:3.1.2:resolve-plugins
06:49:47,547 [main] [INFO] Scanning for projects...
...
...
06:51:04,568 [main] [INFO] Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-11.0.22]
06:51:04,608 [main] [INFO] Changes detected - recompiling the module! :source
06:51:04,610 [main] [INFO] Compiling 450 source files with javac [forked debug release 21] to target/classes
06:51:05,021 [main] [INFO] -------------------------------------------------------------
06:51:05,021 [main] [ERROR] COMPILATION ERROR :
06:51:05,021 [main] [INFO] -------------------------------------------------------------
06:51:05,021 [main] [ERROR] error: release version 21 not supported
06:51:05,021 [main] [INFO] 1 error
06:51:05,022 [main] [INFO] -------------------------------------------------------------
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @Nilesh_Mali
You're seeing this error in your AEM Cloud Manager pipeline because your maven-compiler-plugin
is configured to use --release 21
, but Maven is picking up JDK 11 instead of JDK 21, despite Cloud Manager setting Java 21 (.cloudmanager/java-version
).
Here’s the key error:
[ERROR] error: release version 21 not supported
And this:
Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-11.0.22]
indicates it's still using JDK 11, not 21.
Solution
Cloud Manager provides JDK 21, but Maven uses toolchains to decide which JDK to compile with. You need to explicitly configure a toolchains.xml
file.
Create or update a .cloudmanager/config.yaml
file (if you don’t already have one) and make sure it includes: java-version: "21"
Provide a proper toolchains.xml
in your repo root or .cloudmanager
folder with JDK 21 config.
Here’s an example toolchains.xml
:
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>21</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>/opt/java/openjdk-21</jdkHome>
</configuration>
</toolchain>
</toolchains>
Make sure /opt/java/openjdk-21
is the correct path on Cloud Manager (it usually is for Java 21).
Hope that helps you!
Regards,
Santosh
Views
Replies
Total Likes
Hi @Nilesh_Mali
I think 21 is supported so it should be working.
Views
Replies
Total Likes
Though Java 21 is available in AEM Cloud (as per .cloudmanager/java-version), the Maven build is still using JDK 11 when compiling - the maven-compiler-plugin is using a Java 11 toolchain as per trace you shared :
Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-11.0.22]
You should configure the toolchain to use Java 21
Hi @Nilesh_Mali
You're seeing this error in your AEM Cloud Manager pipeline because your maven-compiler-plugin
is configured to use --release 21
, but Maven is picking up JDK 11 instead of JDK 21, despite Cloud Manager setting Java 21 (.cloudmanager/java-version
).
Here’s the key error:
[ERROR] error: release version 21 not supported
And this:
Toolchain in maven-compiler-plugin: JDK[/usr/lib/jvm/jdk-11.0.22]
indicates it's still using JDK 11, not 21.
Solution
Cloud Manager provides JDK 21, but Maven uses toolchains to decide which JDK to compile with. You need to explicitly configure a toolchains.xml
file.
Create or update a .cloudmanager/config.yaml
file (if you don’t already have one) and make sure it includes: java-version: "21"
Provide a proper toolchains.xml
in your repo root or .cloudmanager
folder with JDK 21 config.
Here’s an example toolchains.xml
:
<toolchains>
<toolchain>
<type>jdk</type>
<provides>
<version>21</version>
<vendor>oracle</vendor>
</provides>
<configuration>
<jdkHome>/opt/java/openjdk-21</jdkHome>
</configuration>
</toolchain>
</toolchains>
Make sure /opt/java/openjdk-21
is the correct path on Cloud Manager (it usually is for Java 21).
Hope that helps you!
Regards,
Santosh
Views
Replies
Total Likes
Thank you for support, Its working after adding above changes, additionally I added build is executed with Java21.
Thank you for your support. It's working after applying the above changes. Additionally I added below plugin and I made sure the build is executed using Java 21.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-toolchains-plugin</artifactId>
<version>1.1</version>
<executions>
<execution>
<goals>
<goal>toolchain</goal>
</goals>
</execution>
</executions>
<configuration>
<toolchains>
<jdk>
<version>21</version>
<vendor>Oracle</vendor>
</jdk>
</toolchains>
</configuration>
</plugin>
Please remove entire toolchain plugin part from your main pom.xml
Just the cloudmanager/java-version file should work fine. I have tested this and it works fine.
Views
Likes
Replies
Views
Likes
Replies