Instructions for updating Jenkins to Java 21: https://www.jenkins.io/doc/book/platform-information/upgrade-java-to-21/
Did you miss this step?
Upgrade to Java 21 on your Jenkins controller
Stop the Jenkins controller with systemctl stop jenkins.
Install the corresponding Java version with dnf -y install temurin-21-jdk or with the package manager your system uses.
Check the Java version with java -version.
Change the default Java for the system by running update-alternatives --config java and then enter the number that corresponds to Java 21, for example 2 if that is the correct option.
Restart Jenkins with systemctl restart jenkins.