1
votes

I run a Spring Cloud Data Flow server on Cloudfoundry (Swisscom). I'm able to properly register a task (Spring Boot), but the task fails to start because of the wrong java runtime being used:

   2019-08-26T11:30:41.57+0200 [APP/TASK/t1-x/0] OUT JVM Memory Configuration: -Xmx435467K -Xss1M -XX:ReservedCodeCacheSize=240M -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=101108K
   2019-08-26T11:30:41.80+0200 [APP/TASK/t1-x/0] ERR Exception in thread "main" java.lang.UnsupportedClassVersionError: ch/xxx/task1/Task1Application 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
   2019-08-26T11:30:41.80+0200 [APP/TASK/t1-x/0] ERR    at java.lang.ClassLoader.defineClass1(Native Method)

Sure this is caused by the cloudfoundry java_buildpack not using the correct java version. Usually this is easy to fix, I just pass the following env variable while deploying the application:

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

but how do I do this when SCDF is deploying the taks-application? I know there is a parameter deployer.cloudfoundry.buildpack=java_buildpack which I can use when I start the task, but how can I pass arguments/environment variables to the buildpack?

Update:

as for now, there are two open issues regarding this issue:

2
You would want to have the SCDF deployer set an environment variable JBP_CONFIG_OPEN_JDK_JRE, that way the env variable is set when the Java buildpack runs. I looked through the docs and didn't see a way to do this for Cloud Foundry. You could always cf set-env and update it after the fact, then restage your app but that's definitely not a nice user experience.Daniel Mikusa
thanks daniel, that's about what I have written in my questiondomi
Another less than perfect option would be to bundle up your own Java buildpack with the default OpenJDK version set to 11. It's fairly easy to do, git clone, check out the release you want, edit openjdk config file and update default version, run the commands here, github.com/cloudfoundry/java-buildpack#building-packages, to package and upload your buildpack. Not a great choice, but it's an option.Daniel Mikusa
thanks Daniel, but I think that will also not work because of this: github.com/spring-cloud/spring-cloud-dataflow/issues/3466domi

2 Answers

0
votes

It looks like environment variables are specified as properties in the task definition. See https://github.com/spring-cloud/spring-cloud-deployer-cloudfoundry/blob/master/src/main/java/org/springframework/cloud/deployer/spi/cloudfoundry/CloudFoundryAppDeployer.java#L278

In this case, you have to set the deployment property for the Cloud Foundry deployer use-spring-application-json=false

Also note that environment variables are applied when pushing the app which only happens the first time the task is launched. If the app already exists, you need to delete it for this to take effect.

0
votes

You can pass the deployer properties when launching the task like this:

task launch <task-name> --properties "deployer.<app-name>.cloudfoundry.<deployerProperty>"

In this case, to pass the buildpack deployer property, you can do:

task launch <task-name> --properties "deployer.<app-name>.cloudfoundry.buildpack=<?>"