Symptoms
When attempting to start Tomcat, it fails with the following error:
Unsupported major.minor version 51.0
Description
This issue is due to Tomcat referencing an outdated version of Java.
You can confirm this via the following steps:
First, determine the JRE_HOME or JAVA_HOME being used by Tomcat.
# /opt/cpanel/ea-tomcat85/bin/./configtest.sh
Using CATALINA_BASE: /opt/cpanel/ea-tomcat85
Using CATALINA_HOME: /opt/cpanel/ea-tomcat85
Using CATALINA_TMPDIR: /opt/cpanel/ea-tomcat85/temp
Using JRE_HOME: /usr/java/latest
Using CLASSPATH: /opt/cpanel/ea-tomcat85/bin/bootstrap.jar:/opt/cpanel/ea-tomcat85/bin/tomcat-juli.jar
Using CATALINA_PID: /var/run/ea-tomcat85/catalina.pid
Exception in thread "main" java.lang.UnsupportedClassVersionError: org/apache/catalina/startup/Bootstrap : Unsupported major.minor version 51.0
Now, using the path in JRE_HOME, find the version that is being used.
# /usr/java/latest/bin/java -version
java version "1.6.0_13"
Java(TM) SE Runtime Environment (build 1.6.0_13-b03)
Java HotSpot(TM) Server VM (build 11.3-b02, mixed mode)
Tomcat 8.5 requires Java version 1.8.
Workaround
First, confirm the Java version in /usr/bin is version 1.8.
# /usr/bin/java -version
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM (build 25.252-b09, mixed mode)
Then, add the following to the /etc/bashrc file to inform Tomcat of the correct location of the Java 1.8 installation.
# nano /etc/bashrc
export JRE_HOME="/usr"