Cloud Foundry – Push Application into Space

As we have already created sample greet application in previous post Cloud Foundry – Create First Application, we will see how we can push the same application into Cloud Foundry development space. As we have already seen, there is a PUSH command in Cloud Foundry Commands. We need to use the same command to push our application into Cloud Foundry. Prior to that, we need to login into the Cloud Foundry CLI by using LOGIN command. If you have any issues with login into the Cloud Foundry by using CF-CLI, look into previous post which I have already explained. The below are the steps which require to follow to push our application into Cloud Foundry,

Open CF-CLI and navigate into the application target directory, target directory will be created automatically as on when we issue mvn clean install command on project.

Now, we can issue the below command to deploy application jar file into Cloud Foundry.

cf push cfgreet -p CFGreet-0.0.1-SNAPSHOT.jar

cf push is the command used for pushing the application
cfgreet is my application name
-p is the path specifying
CFGreet-0.0.1-SNAPSHOT.jar is the actual CFGreet application which we are trying to deploy into cloud foundry.

Pushing Log:

C:\Users\subbaiah\Downloads\CF\CFGreet\CFGreet\target>cf push cfgreet -p CFGreet-0.0.1-SNAPSHOT.jar
Pushing app cfgreet to org javaisocean / space development as…
Getting app info…
Creating app with these attributes…
+ name:       cfgreet
  path:       C:\Users\subbaiah\Downloads\CF\CFGreet\CFGreet\target\CFGreet-0.0.1-SNAPSHOT.jar

Creating app cfgreet…
Mapping routes…
Comparing local files to remote cache…
Packaging files to upload…
Uploading files…
 311.17 KiB / 311.17 KiB [=================================================================================] 100.00% 7s

Waiting for API to complete processing files…

Staging app and tracing logs…
   Downloading binary_buildpack…
   Downloading nodejs_buildpack…
   Downloading java_buildpack…
   Downloading staticfile_buildpack…
   Downloading go_buildpack…
   Downloaded java_buildpack
   Downloading dotnet_core_buildpack_beta…
   Downloaded binary_buildpack
   Downloading hwc_buildpack…
   Downloaded nodejs_buildpack
   Downloading python_buildpack…
   Downloaded staticfile_buildpack
   Downloading ruby_buildpack…
   Downloaded hwc_buildpack
   Downloading dotnet_core_buildpack…
   Downloaded dotnet_core_buildpack_beta
   Downloading php_buildpack…
   Downloaded python_buildpack
   Downloaded ruby_buildpack
   Downloaded php_buildpack
   Downloaded dotnet_core_buildpack
   Downloaded go_buildpack
   Cell 4ae961ca-0fe4-4c10-acc6-cffcd81c918a creating container for instance 5679e3c5-7131-46ec-98ea-9b326b578b66
   Cell 4ae961ca-0fe4-4c10-acc6-cffcd81c918a successfully created container for instance 5679e3c5-7131-46ec-98ea-9b326b578b66
   Downloading app package…
   Downloaded app package (15.5M)
   —–> Java Buildpack v4.16 (offline) |
   —–> Downloading Jvmkill Agent 1.16.0_RELEASE from (found in cache)
   —–> Downloading Open Jdk JRE 1.8.0_181 from (found in cache)
          Expanding Open Jdk JRE to .java-buildpack/open_jdk_jre (1.2s)
          JVM DNS caching disabled in lieu of BOSH DNS caching
   —–> Downloading Open JDK Like Memory Calculator 3.13.0_RELEASE from (found in cache)
          Loaded Classes: 13753, Threads: 250
   —–> Downloading Client Certificate Mapper 1.8.0_RELEASE from (found in cache)
   —–> Downloading Container Security Provider 1.16.0_RELEASE from (found in cache)
   —–> Downloading Spring Auto Reconfiguration 2.5.0_RELEASE from (found in cache)
   Exit status 0
   Uploading droplet, build artifacts cache…
   Uploading droplet…
   Uploading build artifacts cache…
   Uploaded build artifacts cache (131B)
   Uploaded droplet (62.2M)
   Uploading complete
   Cell 4ae961ca-0fe4-4c10-acc6-cffcd81c918a stopping instance 5679e3c5-7131-46ec-98ea-9b326b578b66
   Cell 4ae961ca-0fe4-4c10-acc6-cffcd81c918a destroying container for instance 5679e3c5-7131-46ec-98ea-9b326b578b66

Waiting for app to start…

name:              cfgreet
requested state:   started
last uploaded:     Wed 03 Oct 18:17:54 IST 2018
stack:             cflinuxfs2
buildpacks:        client-certificate-mapper=1.8.0_RELEASE container-security-provider=1.16.0_RELEASE
                   java-main java-opts java-security jvmkill-agent=1.16.0_RELEASE open-jdk-…

type:            web
instances:       1/1
memory usage:    1024M
start command:   JAVA_OPTS=”-agentpath:$PWD/.java-buildpack/open_jdk_jre/bin/jvmkill-1.16.0_RELEASE=printHeapHistogram=1
       $PWD/.java-buildpack/java_security/ $JAVA_OPTS” &&
                 -totMemory=$MEMORY_LIMIT -loadedClasses=14531 -poolType=metaspace -stackThreads=250
                 -vmOptions=”$JAVA_OPTS”) && echo JVM Memory Configuration: $CALCULATED_MEMORY && JAVA_OPTS=”$JAVA_OPTS
                 $PWD/.java-buildpack/open_jdk_jre/bin/java $JAVA_OPTS -cp $PWD/.

       state              since                              cpu         memory              disk
#0   running   2018-10-03T12:48:27Z   129.1%   307.4M of 1G   142.9M of 1G
====================End of LOG==========================================

Now, we check from Pivotal account from UI and check CFGreet application is present or not in development space.

My CFGreet app is present in development space with the Route of Let’s access our API along with this route, the output will be look like Hello javaisocean… Welcome to Cloud Foundry 🙂

Now, your application Successfully pushed into Cloud Foundry and running. 

Previous: Cloud Foundry – Create First Application

Next: PCF Application Services

Cloud Foundry – Create First Application

As of now, we have covered the concepts like download and install CF – CLI, Login into Space from CLI. Now, we look at how to create our first application to deploy into Cloud Foundry Space. Here I am explaining how to create a basic Spring Boot application from Spring Initilizr to deploy into Cloud Foundry. If you already have an application ready to deploy into Cloud Foundry, you can ignore this post. Otherwise please follow the below.
Create and download a project from Spring Initializr by choosing the modules like WEB, DEVTOOLS, REST REPOSITORIES. Then extract into specific location and import it into your IDE(Eclipse, Intellij, etc) to do small modifications.

Then create a Controller class which is annotated with @RestController and add a method which is also annotated with @GetMapping(path=”/greet/{name}”). It look like below,

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

public class GreetService {

 @GetMapping(path = "/greet/{name}")
 public String greetWithName(@PathVariable String name) {

  return "Hello " + name + "... Welcome to Cloud Foundry :)";



Add the @EnableAutoConfiguration along with existing @SpringBootApplication to the main class of the application. So, it will get identified all the components and controllers present in the application. My main class look like below,

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class CfGreetApplication {

 public static void main(String[] args) {, args);

Now, Run your application and access the API present in Controller/Service class. As per the above code http://localhost:8080/greet/javaisocean
As on when you hit the above API in browser, you will get the response saying Hello javaisocean… Welcome to Cloud Foundry 🙂

In coming post we will look at how to deploy this application into Cloud Foundry. Prior to that, we need to create a Jar file of this application by using mvn clean install.

Previous: Cloud Foundry Commands

Next: Cloud Foundry – Push application into Space