Skip to Content

The following steps will explain how to create the very first HelloWorld example on SAP Cloud Platform Cloud Foundry using the SAP S/4HANA Cloud SDK. If you want to follow this tutorial, we highly recommend checking out the first part of this blog series.

Note: This post is part of a series. For a complete overview visit the SAP S/4HANA Cloud SDK Overview.


Goal of this blog post

This tutorial will cover your first steps when developing applications for SCP CloudFoundry using the SAP S/4HANA Cloud SDK. More specifically, we will cover the following steps:

  1. Create an account for SCP CloudFoundry and setup the CloudFoundry command line interface for deploying and managing CloudFoundry applications.
  2. Generate your first project using the SAP S/4HANA Cloud SDK Maven archetype and understand its structure.
  3. Deploy your first application to SCP CloudFoundry.

The screenshot below shows the final result of this tutorial.


Setup for CloudFoundry

In order to deploy applications to SCP CloudFoundry, you need to create a free trial account. You can create your account by visiting

After creating your account and activating it via email, you can log in to your personal cloud cockpit. For your first visit, it should look like this:

Now click the “Home” button in the upper navigation bar and then click “Start Cloud Foundry Trial”.

After selecting your region, your account will be automatically setup for development with CloudFoundry.

Now that your account is activated and configured, you will need the CloudFoundry command line interface (cf CLI) to deploy and manage your CloudFoundry applications.

To install cf CLI, you can either grab the latest release on the official release page or use your favorite package manager.

In order to deploy applications on SAP CloudFoundry we need to provide cf CLI with an API endpoint. The API endpoint depends on the region you chose for your account:

  • for EU:
  • for US EAST:
  • for US WEST (beta):

Now enter the following commands (in this case for the EU region):

cf api
cf login

The cf CLI will ask you for your mail and your password. After entering these, you should be successfully logged in!

Generate Project from Archetype

To generate your first project from the Maven archetype, run the following command:

mvn archetype:generate -DarchetypeArtifactId=scp-cf-tomee -DarchetypeVersion=LATEST

During the generation process, Maven will require additional parameters to form your project:

groupId An identifier representing your group, company or organization (e.g.
artifactId An identifier for your application (e.g. firstapp)
version The version of your application (e.g. 1.0-SNAPSHOT)
package The name of the top-level package your source code will reside in (typically equal to your groupId, e.g. Please pay attention to package and directory names in any upcoming source code when using a different package name than suggested here.

(versions 1.0.0 1.8.0)

An unique identifier to determine your initial project URL on CloudFoundry. This value must be unique across your CloudFoundry region, but it can easily be changed later on. We recommend Application Name + some random number, e.g.: firstapp-D123456

After providing these values, Maven will generate your project from the archetype.

Note: We have created here an application which is based on the TomEE runtime which is Java EE 6 compliant OpenSource runtime that is available in the Cloud Foundry platform if you aim at a Java EE application. You may also initialize the project with SpringBoot (artifactId: scp-cf-spring) or on a pure Tomcat container (artifactId: scp-cf-tomcat). Our tutorial series will be primarily based on the TomEE runtime, we may cover flavors in SpringBoot or Tomcat later in this blog. Nonetheless, the SAP S/4HANA Cloud SDK is compatible with these popular runtimes too.

Understand the project structure and its artifacts

Now you can open your favorite IDE and import the project as ‘Maven Project’. After importing the project into your IDE, the project structure should look like this:

The first thing you will notice, is the different directories:

  • application
  • cx-server
  • integration-tests
  • unit-tests

These are Maven sub-modules and they serve different aspects of your code application, test and deployment environment. The following separation of modules makes it possible to run dedicated unit tests and sensitive integration tests without deploying the application.

Multiple modules project

The advantage of operating a multiple modules project for your application becomes apparent as soon as the software complexity rises. Then it gets convenient to dedicate code distribution and responsibility to developers for either application or test environment. In terms of reliability and continuance, you will see, that front-end testing and test-automation are as important as classic backend-testing of your project. These fields of expertise require different programming paradigms, and such different kinds of development life cycles. To ensure the overall software stability and liability, a multiple modules setup is the best practice solution.

To get you started, we take a look into the conventional application project, as well as the classic unit tests. Then the integration tests follow, used for code tests with external servers and resources. Once software testing is covered, we briefly introduce the Cx server for continuous integration and delivery.

  • application contains the source code and configuration of your actual web application.

    src/main/java Here goes your production code, nothing else. As you can see, there’s already the HelloWorldServlet, which we will look at in more detail soon.
    src/main/resources Anything that you require in your production code but is no compilable code goes here (typically things like API definition files for RAML or OpenAPI, Database Migration Files for Flyway or Liquibase)
    src/main/webapp contains the deployment descriptor for your web application – the infamous web.xml
    src/test/java Additional test classes.
    src/test/resources Additional resources for attached test modules.
    pom.xml This is your project management file for Maven where you can maintain other open source dependencies or use plugins that ease your build Environment.


  • unit-tests contains the unit tests for your application. Its structure is similar to application but it exclusively holds test classes and resources. The purpose of this module is to test and validate single aspects of data flow and computational operations in the application project.

    src/test/java This is the place for your automated tests.
    src/test/resources Tests may also require additional resources to work properly such as configuration files. This is their place.


  • integration-tests contains the integration tests for your application. Its structure is similar to application.

    src/test/java Here you can put all your integration tests. As you can see, there’s already the HelloWorldServiceTest corresponding to the HelloWorldServlet.
    src/test/resources Here are all the resources needed for the integration tests to run or validate.


  • cx-server contains the script and configuration file to manage your best practice continuous integration and delivery software environment (Cx). The including files allow Linux users to simply create your very own Cx server as part of a Docker deployment. The server, which will be run, is Jenkins. This automation server helps to manage all technical steps of a software development process.

    cx-server This Unix bash script allows you to start and stop the Jenkins server on your local machine, as part of a Docker container.
    server.cfg This is the configuration file for the server parameters.

    Once a Jenkins server is configured for your personal needs, the files in the project root directory become useful:

    Jenkinsfile This text file contains the definition of a Jenkins Pipeline and stays part of your project source code. It defines what steps are run specifically for your application.
    pipeline_config.yml This is the configuration file for your specific application.


  • manifest.yml is the deployment descriptor for CloudFoundry.
    We will take a closer look at this file once we deploy the application.

Unit tests and integration tests

This separation of test modules makes it possible to just run unit tests and integrations test without deploying, as well as deploying the application without running time consuming tests. Unit tests can either be kept publicly inside the application module, or in the separate unit-tests folder, that’s part of the archetype. For that topic we highly recommend the articles and educational videos from Martin Fowler. For a start we advice reading his post about Unit Tests.

During development it becomes important to test newly implemented code to external services, i.e. logic running in a distributed environment. This is where an integration test is an important tool to ensure correctness and stability over the whole internal and external deployment. Since the integration tests may contain confidential information, like business logic and test access tokens, it can be helpful to maintain its operation inside a dedicated Maven sub module. That way the runnable application itself can be later shipped without tests and their dependency.


Now that you understand the structure of the project, let’s take a closer look at the HelloWorldServlet.


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class HelloWorldServlet extends HttpServlet
    private static final long serialVersionUID = 1L;
    private static final Logger logger = LoggerFactory.getLogger(HelloWorldServlet.class);
    protected void doGet( final HttpServletRequest request, final HttpServletResponse response )
        throws ServletException, IOException
    {"I am running!");
        response.getWriter().write("Hello World!");

The HelloWorldServlet extends HttpServlet, so this will be a HTTP endpoint that we can visit. We map this endpoint to the /hello route using @WebServlet("/hello"). By overriding the function doGet, we define what happens when a client performs an HTTP GET request on the /hello route. in this case we simply write a response containing “Hello World!”.

Note: The application code runs seamlessly in SAP Cloud Platform, Neo as well as SAP Cloud Platform, Cloud Foundry. The SAP S/4HANA Cloud SDK is compatible with both versions and provides mechanisms to seamlessly transfer code between both environments.


In order to deploy the application, we first need to assemble our project into a deployable artifact – a .war file. Open your command line and change into the firstapp directory, the root directory of your project and run the following command:

cd /path/to/firstapp
mvn clean package

This tells maven to remove any files from previous assemblies (clean) and to assemble our project (package). The project is setup so that Maven automatically runs our unit and integration tests for us. After running the command there should be a directory target inside of the applicationdirectory, containing a file called firstapp-application.war. This is the file that we will deploy to Cloud Foundry (or locally).

Deploy to Cloud Foundry

Now the previously mentioned manifest.yml comes into play – it’s the deployment descriptor used by Cloud Foundry. A default version has been generated by the archetype. In order have enough memory available also for later steps of this tutorial series, please make sure to have the instance memory set to 768 MB. Also the environment variable JBP_CONFIG_SAPJVM_MEMORY_SIZES should be declared as shown below.


- name: firstapp
  memory: 768M
  host: firstapp-D123456
  # random-route: true # used instead of "host"
  path: application/target/firstapp-application.war
  buildpack: sap_java_buildpack
    JBP_CONFIG_SAPJVM_MEMORY_SIZES: "metaspace:96m.."

The manifest contains a list of applications that will be deployed to Cloud Foundry. In this example we only have one application, firstapp, with the following parameters:

name This is the identifier of your application within your organization and your space in SCP CloudFoundry.
memory The amount of memory allocated for your application.
host Determines the URL of your application after deploying it.
random-route Set to true if you want the application instance to be hosted to a random route. This ensures that the URL of your application is unique and as such avoids name collisions. The random route is created once for the application instance and will be kept even after restart. Please note: This will only work, if no host setting is provided.
path The relative path to the artifact to be deployed.
buildpack A buildpack is what CloudFoundry uses to build and deploy your application. Since this is a Java application, we use the sap_java_buildpack.
env Here we can provide additional application specific environment variables. For example we specify that we want to use a TomEE container as our target runtime.

Now you can deploy the application by entering the following command:

cf push

cf push is the command used to deploy applications. The -f flag provides cf CLI with the deployment descriptor.

Hint: If you omit the -f flag,  cf CLI will check whether there is a file named manifest.yml in the current directory. If so,  cf CLI will use this file as deployment descriptor. Else, it will fail.

After the deployment is finished, cf CLI’s output should look like this:

Now we can visit the application under its corresponding URL as it is shown in the output above. Take the value from “urls: ...” and append the “/hello” path:

Hello world!

That’s it.

Run the Application on a Local Server

Since version 1.1.1 of the SAP S/4HANA Cloud SDK, the generated projects can also be run locally out-of-the-box. To do so, first assemble the project using the mvn clean package command (see above).

Then, run the following commands to start the local server:

cd application
mvn tomee:run

Visit http://localhost:8080/hello on your local machine to view the response of our application. You can stop the server by pressing Ctrl + C.

Now you have a strong basis for developing your own cloud application for SCP Cloud Foundry using the SAP S/4HANA Cloud SDK. Stay tuned for upcoming blog posts about more advanced usages of the SAP S/4HANA Cloud SDK.

See the next tutorial in the series here: Step 4 with SAP S/4HANA Cloud SDK: Calling an OData Service.



Windows PowerShell

If you are using Powershell on Windows, always put Maven arguments (supplied with -D) in quotes, for example:

mvn archetype:generate "" "-DarchetypeArtifactId=scp-cf-tomee" "-DarchetypeVersion=LATEST"
To report this post you need to login first.


You must be Logged on to comment or reply to a post.

  1. Former Member

    Hi Alexander,



    I am stuck with the below step:

    Now enter the following commands (in this case for the EU region):

    cf api
    cf login

    prior to this i have downloaded and  executed the files cf-cli_6.33.1_winx64 and cf-cli_edge_winx64 ( CloudFoundry command line interface (cf CLI) ) ,the cmd window mode just popes up and closed after executing both .exe files,then I tried to copy past the file in Cmd as below.


    Could you please guide me where to execute those 2 line of commands?Thank you.



    1. Daniel Kurzynski

      Hi  Sathishkumar,

      have you used the binaries or the installer?

      You should download the installer from the following webpage (select Windows):

      Inside the zip you will a file called cf_installer.exe. Executing this file should guide you through the installation process.

      The steps are also described here:

      Best Regards,




  2. Oliver Merk

    Hi Alexander,

    Trying to run the application on a Local Server using mvn tomee:run leads to the following error:

    [ERROR] No plugin found for prefix ‘tomee’ in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local …]), central (] -> [Help 1]
    org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix ‘tomee’ in the current project and in the plugin groups

    Any ideas how to fix it?

    Best regards


    1. Alexander Duemont Post author

      Hi Oliver,

      Please run “mvn tomee:run” from within the “./application” directory. Alternatively you can run “mvn tomee:run -f application” from your project root.

      If this does not solve your issue, please let us know SDK version number and consider attaching the POM files “./pom.xml” and “./application/pom.xml“.

      Best regards


  3. Oliver Merk

    Hi Alexander,

    Please also explain how to run the application locally in case using spring which leads to an jar instead of war.

    Thanks in advance.

    Best regards


    1. Alexander Duemont Post author

      Hi Oliver,

      Applications, built by using the Spring archetype, can be run locally by “mvn spring-boot:run” within the “application” directory. Alternatively you can run “mvn tomee:run -f application” from your project root.

      Best regards


  4. Amit Kulkarni

    Hi Alexandra,

    I have done all the setups to build the project firstapp however my manifest.yml did not created automatically while I am trying to push the project it is getting failed is there anything I am missing any step.



    1. Christoph Schubert

      Hi Amit,

      the manifest.yml should be created when you execute the “mvn archetype:generate …” command at the beginning of the guide. Can you please check this by setting up a new project in an empty directory?
      Also, regarding the push problem, can you please provide the output of the “cf push” command? That way we can probably pin point the issue.

      Best regards

      1. Amit Kulkarni

        Hi Christoph,


        Thanks for your prompt reply please find the below cf push log


        Pushing app to org S0019145314trial_trial / space dev as amit.c.kulkarni..
        Incorrect usage: The push command requires an app name. The app name can be supplied as an argument or with a manifest.yml file.

        push – Push a new app or sync changes to an existing app

        cf push APP_NAME [-b BUILDPACK_NAME] [-c COMMAND] [-f MANIFEST_PATH | –no-manifest] [–no-start]
        [-i NUM_INSTANCES] [-k DISK] [-m MEMORY] [-p PATH] [-s STACK] [-t HEALTH_TIMEOUT] [-u (process | port | http)]
        [–no-route | –random-route | –hostname HOST | –no-hostname] [-d DOMAIN] [–route-path ROUTE_PATH] [–var KEY=VALUE] [–vars-file VARS_FILE_PATH]…

        cf push APP_NAME –docker-image [REGISTRY_HOST:PORT/]IMAGE[:TAG] [–docker-username USERNAME]
        [-c COMMAND] [-f MANIFEST_PATH | –no-manifest] [–no-start]
        [-i NUM_INSTANCES] [-k DISK] [-m MEMORY] [-t HEALTH_TIMEOUT] [-u (process | port | http)]
        [–no-route | –random-route | –hostname HOST | –no-hostname] [-d DOMAIN] [–route-path ROUTE_PATH] [–var KEY=VALUE] [–vars-file VARS_FILE_PATH]…

        cf push APP_NAME –droplet DROPLET_PATH
        [-c COMMAND] [-f MANIFEST_PATH | –no-manifest] [–no-start]
        [-i NUM_INSTANCES] [-k DISK] [-m MEMORY] [-t HEALTH_TIMEOUT] [-u (process | port | http)]
        [–no-route | –random-route | –hostname HOST | –no-hostname] [-d DOMAIN] [–route-path ROUTE_PATH] [–var KEY=VALUE] [–vars-file VARS_FILE_PATH]…

        cf push -f MANIFEST_WITH_MULTIPLE_APPS_PATH [APP_NAME] [–no-start]


        -b Custom buildpack by name (e.g. my-buildpack) or Git URL (e.g. ‘’) or Git URL with a branch or tag (e.g. ‘’ for ‘v3.3.0’ tag). To use built-in buildpacks only, specify ‘default’ or ‘null’
        -c Startup command, set to null to reset to default start command
        -d Domain (e.g.
        –docker-image, -o Docker-image to be used (e.g. user/docker-image-name)
        –docker-username Repository username; used with password from environment variable CF_DOCKER_PASSWORD
        –droplet Path to a tgz file with a pre-staged app
        -f Path to manifest
        –health-check-type, -u Application health check type (Default: ‘port’, ‘none’ accepted for ‘process’, ‘http’ implies endpoint ‘/’)
        –hostname, -n Hostname (e.g. my-subdomain)
        -i Number of instances
        -k Disk limit (e.g. 256M, 1024M, 1G)
        -m Memory limit (e.g. 256M, 1024M, 1G)
        –no-hostname Map the root domain to this app
        –no-manifest Ignore manifest file
        –no-route Do not map a route to this app and remove routes from previous pushes of this app
        –no-start Do not start an app after pushing
        -p Path to app directory or to a zip file of the contents of the app directory
        –random-route Create a random route for this app
        –route-path Path for the route
        -s Stack to use (a stack is a pre-built file system, including an operating system, that can run apps)
        –vars-file Path to a variable substitution file for manifest; can specify multiple times
        –var Variable key value pair for variable substitution, (e.g., name=app1); can specify multiple times
        -t Time (in seconds) allowed to elapse between starting up an app and the first healthy response from the app

        CF_STAGING_TIMEOUT=15 Max wait time for buildpack staging, in minutes
        CF_STARTUP_TIMEOUT=5 Max wait time for app instance startup, in minutes
        CF_DOCKER_PASSWORD= Password used for private docker repository

        SEE ALSO:
        apps, create-app-manifest, logs, ssh, start

        also we  have raised the SAP ticket and got the reply there are only specific BAPI’s only we can we are following these series of blog to complete our POC to call




        Hi Amit,


        yes BAPI_SALESORDER_SIMULATE was white listed to be called from SAP onPremise systems via the cloud connector into the S/4HANA Cloud.

        But this whitelisting does not directly enable the BAPI to be used as described in the blog post.

        At some point the blog post mentions the list of BAPIs that were enabled for cloud SDK.


        We do not intend to enable BAPI_SALESORDER_SIMULATE to be used in cloud SDK, as we want to cover the functionality of simulating the creation of a sales order in an synchronous call by providing an OData API Service.





        1. Christoph Schubert

          Hi Amit,

          this output is to be expected if no manifest.yml could be found in your current directory.

          Therefore, can you please verify whether the “mvn archetype:generate …”, as specified in the blog above, creates a manifest.yml file on your system?

          Best regards


  5. Andreas Muno

    Hi, with command

    cf push

    I get all positive cf responses until

    Creating app firstapp…
    Mapping routes…
    You have exceeded the total routes for your organization’s quota.

    What do I have to do in my CF subaccount to fix that? Or is the issue somewhere else?


Leave a Reply