Re: Passing arguments to a spring boot main implementing command line runner to be called by pcf scheduler service

Daniel Mikusa

On Wed, Oct 25, 2017 at 1:26 PM, shruthi s <shruthi.sambasivan(a)>

Let me give some more details of what i am doing and what i want to

I use a manifest file and upload the jar of my project and do not want it
to start the application. The manifest file looks like :
- name: my_app_name
memory: 1024M
host: my_app_service
health-check-type: process
instances: 1
timeout: 180
path: my_apps_java_executable.jar
no-route: true
JBP_CONFIG_JAVA_MAIN: '{ arguments: "arg0 arg1" }'

i run this command to push the app "cf push -f manifest.yml --no-start"

This works OK. Then i am trying to check if i can run the jar using "java"
command by running a task against my_app_name

cf run-task my_app_name "java -jar my_apps_java_executable.jar" --name

This gave an error: "java command not found"

i tried this
cf run-task my_app_name "$PWD/.java-buildpack/open_jdk_jre/bin/java -jar
my_apps_java_executable.jar" --name my_task1
This won't work because there is no jar file. When you `cf push` your app,
it extracts the contents of the JAR and uploads the contents not the JAR.
The root of your app folder is going to be the root of your JAR file. You
also need single quotes or `$PWD` is going to be evaluated by your local

For a Spring Boot app, I had to do this: `cf run-task java-cli-demo
'$PWD/.java-buildpack/open_jdk_jre/bin/java -cp $PWD/.
org.springframework.boot.loader.JarLauncher arg0 arg1'`.

The `-cp` sets the classpath to the current directory, i.e. the root of my
JAR & then I use the JarLauncher class of Spring Boot to start the app.
Pass any arguments onto the end. The values you set in
JBP_CONFIG_JAVA_MAIN aren't going to apply for the command here.


Join to automatically receive all group messages.