How to set Java version in Java Buildpack for Spring Cloud Dataflow for VMs tasks
search cancel

How to set Java version in Java Buildpack for Spring Cloud Dataflow for VMs tasks

book

Article ID: 298379

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

You may need to change the default Java version for the tasks you run with Spring Cloud Dataflow for VMs. This is needed, for example, if you update the java version for which the tasks are compiled, so you don't get an Exception as the following one when running the task
 
[ERR] Exception in thread "main" java.lang.UnsupportedClassVersionError: com/spatial/batch/BatchApplication 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


Environment

Product Version: 2.12

Resolution

One possible solution is configuring the properties when launching the task. E.g
 
task launch mytask --properties "deployer.mytask.cloudfoundry.env.JBP_CONFIG_OPEN_JDK_JRE={ jre: { version: 11.+ } }, deployer.mytask.cloudfoundry.use-spring-application-json=false"

Where "mytask" is the name of the task.

It's very important that you keep the format of JBP_CONFIG_OPEN_JDK_JRE, not deleting any space and not adding any quote (single or double), since changing it may cause a json format error.

Another possible solution is to configure the task apps using cf cli. This can be done from a script in an automation server by changing JBP_CONFIG_OPEN_JDK_JRE directly on the task app deployed in your TAS Tile. E.g.
sh "cf set-env $appname JBP_CONFIG_OPEN_JDK_JRE '{ jre: { version: 11.+ }}'"
sh "cf set-env $appname JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{enabled: false}'"
sh "cf restage $appname"