I have installed Tomcat 11.0.0-M6 and I get this error message every time I want to start it for the first time:
Error: LinkageError occurred while loading main class org.apache.catalina.startup.Bootstrap java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0
I have checked Java version by doing java -version and I get that is version 11 corresponding to the class file version 55 as requested by Tomcat:
java version "11.0.12" 2021-07-20 LTS Java(TM) SE Runtime Environment 18.9 (build 11.0.12+8-LTS-237) Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.12+8-LTS-237, mixed mode)
Then I did update-alternatives --display java and I get:
java - manual mode
link best version is /opt/jdk/jdk-11.0.12/bin/java
link currently points to /opt/jdk/jdk-11.0.12/bin/java
link java is /usr/bin/java
/opt/jdk/jdk-11.0.12/bin/java - priority 100
/opt/jdk/jdk-17.0.7/bin/java - priority 100
/opt/jdk/jdk1.8.0_301/bin/java - priority 100
And we can see that is Java 11 that is used and not Java 17
There is tomcat.service file:
[Unit]
Description="Tomcat Service"
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
RestartSec=10
Restart=always
Environment="JAVA_HOME=/opt/jdk/jdk-11.0.12"
Environment="JAVA_OPTS=-Djava.awt.headless=true -Djava.security.egd=file:/dev/./urandom"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
[Service]
Environment="CATALINA_OPTS=-Djava.library.path=/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu:/usr/lib64:/lib64:/lib:/usr/lib"
Does anyone have any idea what caused the error?
Thanks for your help