Expand my Community achievements bar.

Submissions are now open for the 2026 Adobe Experience Maker Awards.
SOLVED

Java 21: The build is successful locally, but the following error occurs when updating the Java version on AEM Cloud

Avatar

Level 4

[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] -------------------------------------------------------------

 

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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.

How can you Fix

  1. Create or update a .cloudmanager/config.yaml file (if you don’t already have one) and make sure it includes: java-version: "21"

  1. 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


Santosh Sai

AEM BlogsLinkedIn


View solution in original post

5 Replies

Avatar

Community Advisor

Avatar

Employee

@Nilesh_Mali 

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

Avatar

Correct answer by
Community Advisor

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.

How can you Fix

  1. Create or update a .cloudmanager/config.yaml file (if you don’t already have one) and make sure it includes: java-version: "21"

  1. 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


Santosh Sai

AEM BlogsLinkedIn


Avatar

Level 4

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>

  

Avatar

Level 3

@Nilesh_Mali 

Please remove entire toolchain plugin part from your main pom.xml

 

https://experienceleague.adobe.com/en/docs/experience-manager-cloud-manager/content/getting-started/...

 

Just the cloudmanager/java-version file should work fine. I have tested this and it works fine.