Search code examples
springcloud-foundryspring-cloud-dataflow

how to pass arguments to the buildpack when deploying a task on spring cloud data flow running on cloudfoundry?


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:


Solution

  • 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.