Re: Deploying a shell script driven java application to cf

Ben Hale <bhale@...>


Unfortunately, Daniel’s suggestion won’t work. The buildpack expects the filesystem to look like an exploded JAR/WAR and will refuse to stage if it does not. Instead of trying to get your shell script to run inside of the container, you should actually be trying to run your application without a shell script. What exactly does your shell script do? I think you’ll find that the buildpack already does the same things removing the need for it.

-Ben Hale
Cloud Foundry Java Experience, Lead

On Nov 16, 2015, at 04:39, Daniel Mikusa <dmikusa(a)> wrote:

I haven't tried this, but I think it should work.

1.) Make a directory. In that directory put your JAR file, your start script and anything else the app needs to run.
2.) From that directory, run `cf push <app-name> -b java_buildpack -c '$PWD/'`. This will upload your script, the JAR file and everything else in the current directory. It will also tell CF that you specifically want to use the Java build pack (which will install Java) and that you want to use your script to start your app.

What could be tricky about this is your start script. It's going to need to reference JAVA_HOME as `/home/vcap/app/.java-buildpack/open_jdk_jre`, and `java` as `$JAVA_HOME/bin/java` since `java` is not going to be on the $PATH.

You're also going to need to handle some of the things that the JBP would normally do like set -Xmx and other JVM memory settings to keep the JVM from exceeding the containers MEMORY_LIMIT. Note, *all* memory needs to fit under the limit, not just the JVM's heap. In other words, setting -Xmx == MEMORY_LIMIT is 100% wrong.

Beyond that, you'd need to make sure the app is listening on $PORT or if it's not taking web requests, disable that health check (`cf push --no-route` & `cf set-health-check none`).


On Fri, Nov 13, 2015 at 12:47 AM, dammina sahabandu <dammina(a)> wrote:
Hi All,
I have a java application which is a composition of several jars in the running environment. The main jar is invoked by a shell script. Is it possible to push such application into cloud foundry? And if it is possible can you please help me on how to achieve that. A simple guide will be really helpful.

Thank you in advance,

Join { to automatically receive all group messages.