Java app fails to start on VMware Tanzu Application Service(TAS) due to mismatched JRE version
search cancel

Java app fails to start on VMware Tanzu Application Service(TAS) due to mismatched JRE version

book

Article ID: 297993

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Environment

Product Version: 2.7

Resolution

Checklist:

Java app fails to start on VMware Tanzu Application Service (TAS) due to mismatched JRE version.

After deploying a Java app to TAS, the app fails to start due to the error below:

2021-02-19T10:40:52.80+0000 [APP/PROC/WEB/0] ERR Exception in thread "main" java.lang.UnsupportedClassVersionError: org/cloudfoundry/samples/music/Application has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0


This is caused by a mismatched JRE version (with which the app is executed in container) and JDK version (with which the app is compiled). The Java buildpack in TAS supports multiple versions of JRE but the default is v8. In the above error message, 52.0 and 55.0 are the major and minor version numbers and are stored in the class bytecode at bytes six and seven. The major version numbers map to the Java versions below: 
 

  • 45 = Java 1.1
  • 46 = Java 1.2
  • 47 = Java 1.3
  • 48 = Java 1.4
  • 49 = Java 5
  • 50 = Java 6
  • 51 = Java 7
  • 52 = Java 8
  • 53 = Java 9
  • 54 = Java 10
  • 55 = Java 11
  • 56 = Java 12
  • 57 = Java 13
  • 58 = Java 14
  • 59 = Java 15
  • 60 = Java 16
  • 61 = Java 17
  • 62 = Java 18
  • 63 = Java 19
  • 64 = Java 20
  • 65 = Java 21
  • 66 = Java 22

Thus the error message indicates that the app is compiled with JDK v11 and fails to start with JRE v8. To specify JRE version properly, please refer to Java buildpack repository, configure JBP_CONFIG_OPEN_JDK_JRE in deployment manifest as:

env:
    JBP_CONFIG_OPEN_JDK_JRE: '{ jre: { version: 11.+ } }'


Or in the environment variable as:

cf set-env YOUR_APP JBP_CONFIG_OPEN_JDK_JRE '{ jre: { version: 11.+ }}'