Deploying the Migrated Java Application to SAP BTP, Cloud Foundry runtime

Objective

After completing this lesson, you will be able to deploy a migrated Java application and its Application Router to the SAP BTP, Cloud Foundry environment using the Cloud Foundry Command Line Interface to ensure a healthy, functional runtime deployment.

Introduction

This lesson focuses on deploying a migrated Java application to the Cloud Foundry environment. You will learn to use the Cloud Foundry CLI and the MultiApps Cloud Foundry CLI plugin to execute the cf deploy command.

The process involves building the application with Maven and utilizing the mtad.yaml deployment descriptor to manage service entitlements, such as SAP Authorization and Trust Management service (XSUAA). You will understand the architectural shift from a single Neo environment WAR to a dual-module structure featuring a Java backend and an Application Router for secure request routing.

Before You Deploy

Lesson 3.1 produced a fully transformed application and an mtad.yaml deployment descriptor. This lesson covers the next step: getting that application running on Cloud Foundry runtime.

Prerequisites

Two things must be in place before running cf deploy. These are prerequisites, not steps you will perform during this lesson.

  • Cloud Foundry CLI session: You must be logged in to your Cloud Foundry environment. If you are not already logged in, run:

    Code Snippet
    1
    cf login -a <CF_API_ENDPOINT>

    You will be prompted for your credentials and asked to select an org and space. Confirm you are targeting the correct space before proceeding.

  • Service entitlements: The mtad.yaml generated in Lesson 3.1 declares Cloud Foundry CLI services that must be entitled in your subaccount before deployment — at minimum XSUAA and SAP Destination service for the sample application. Provisioning entitlements is outside the scope of this course. If entitlements are not yet in place, coordinate with your SAP BTP administrator before continuing.

To check which services your mtad.yaml requires, look for all type: org.cloudfoundry.managed-service entries in the resources section.

To deploy the migrated application, ask your AI agent:

Code Snippet
1
The migration is complete. Build and deploy the application to SAP BTP, Cloud Foundry runtime.

Watch the video to learn how to deploy your application to the SAP BTP, Cloud Foundry environment using the MultiApps CLI plugin and mtad.yaml file.

Key Takeaways from Video

Key Steps for Deploying Applications to SAP BTP, Cloud Foundry Environment

  • Verify Prerequisites: Before starting, log in to the SAP BTP, Cloud Foundry environment using the Cloud Foundry CLI (cf login) and ensure the subaccount has necessary service entitlements, specifically for the SAP Destination service and the cloud security services integration library (XSUAA).

  • Prepare the Project: Navigate to the migrated project directory and confirm the presence of the deployment descriptor file (mtad.yaml), which is essential for the Multi-Target Application (MTA) deployment.

  • Build the Application: Package the Java backend by running the command mvn clean package -DskipTests to prepare the artifacts for deployment.

  • Execute Deployment: Use the MultiApps Cloud Foundry CLI plugin command cf deploy . -f to read the mtad.yaml directly, allowing for a streamlined deployment that bypasses the need for a separate MTA archive or the MTA build tool (MBT).

  • Deployment Lifecycle: The process automatically handles uploading the package, resolving the deployment plan, provisioning/binding services, and staging both the Java backend and the Node.js Application Router.

  • Architecture & Routing: Once started, the environment separates the Java backend (business logic) from the Application Router (entry point), which manages OAuth 2.0 flows and session management to ensure secure communication.

What You Have After Deployment

Once deployment completes, your Cloud Foundry CLI space contains two running applications:

ModuleTypeRole
Java backendJava application (SAP Java Buildpack)Handles business logic and API requests
Application RouterNode.js application (@sap/approuter)Handles authentication, session management, and request routing

This two-application structure is a fundamental difference from Neo environment. On Neo environment, your single WAR handled everything — including the authentication flow. In Cloud Foundry runtime, authentication is separated out into the Application Router, which sits in front of the Java backend and manages the XSUAA OAuth 2.0 flow on its behalf.

The Application Router is the entry point for browser traffic. It validates the XSUAA token, manages the user session, and forwards authenticated requests to the Java backend. End users access the application through the Application Router's route — not the Java backend's route directly.

Running cf apps after a successful deployment will show both modules:

Code Snippet
123
name requested state instances memory disk urls neo-migration-app started 1/1 1024M 1G neo-migration-app.cfapps.eu10.hana.ondemand.com neo-migration-approuter started 1/1 256M 1G neo-migration-approuter.cfapps.eu10.hana.ondemand.com

The Application Router URL is the one you open in a browser. The backend URL is internal — it receives only requests forwarded by the Application Router.

A Closer Look: mtad.yaml and xs-security.json

The two files generated by the migration skills — mtad.yaml and xs-security.json — encode the key structural differences between Neo environment and Cloud Foundry runtime. Understanding what they contain helps you verify the migration output and troubleshoot if something is not working. The deployment descriptor is essential for the following reasons:

mtad.yaml

The mtad.yaml is the MTA deployment descriptor. It declares all modules (deployable applications) and resources (Cloud Foundry CLI services) in a single file and describes how they relate to each other. On Neo environment, none of this existed — the platform managed it implicitly.

A typical mtad.yaml for a migrated Neo environment application looks like this:

Code Snippet
1234567891011121314151617181920212223242526272829303132333435363738394041
_schema-version: "3.1" ID: neo-migration-app version: 1.0.0 modules: - name: neo-migration-app type: java.tomcat path: neo-migration-app/target/your-app.war parameters: memory: 1024M requires: - name: neo-migration-xsuaa - name: neo-migration-destination - name: neo-migration-approuter type: nodejs path: approuter/ parameters: memory: 256M requires: - name: neo-migration-xsuaa - name: neo-migration-destination group: destinations properties: name: backend url: "~{url}" forwardAuthToken: true resources: - name: neo-migration-xsuaa type: org.cloudfoundry.managed-service parameters: service: xsuaa service-plan: application path: xs-security.json - name: neo-migration-destination type: org.cloudfoundry.managed-service parameters: service: destination service-plan: lite

Key things to notice:

  • Two modules — the Java backend and the Application Router r are declared separately. Both require the XSUAA service instance, but for different reasons: the backend checks authorization, the Application Router handles the token exchange.

  • forwardAuthToken: true — the Application Router forwards the user's XSUAA JSON Web Token (JWT) to the backend on every request. The backend uses it to perform authorization checks.

  • path: xs-security.json — the XSUAA service instance is created using the security descriptor generated by the authentication-xsuaa skill.

xs-security.json

The xs-security.json is the XSUAA security descriptor. It defines the application's OAuth 2.0 scopes, role templates, and role collections. On Neo environment, roles were defined inside the application's web.xml and assigned through the SAP BTP cockpit — there was no equivalent external descriptor.

A typical xs-security.json for a migrated Neo environment application looks like this:

Code Snippet
1234567891011121314151617181920212223242526272829303132333435363738
{ "xsappname": "neo-migration-app", "tenant-mode": "dedicated", "scopes": [ { "name": "$XSAPPNAME.Employee", "description": "Employee access" }, { "name": "$XSAPPNAME.Manager", "description": "Manager access" } ], "role-templates": [ { "name": "Employee", "description": "Employee role template", "scope-references": ["$XSAPPNAME.Employee"] }, { "name": "Manager", "description": "Manager role template", "scope-references": ["$XSAPPNAME.Manager"] } ], "role-collections": [ { "name": "neo-migration-app-Employee", "description": "Employee role collection", "role-template-references": ["$XSAPPNAME.Employee"] }, { "name": "neo-migration-app-Manager", "description": "Manager role collection", "role-template-references": ["$XSAPPNAME.Manager"] } ] }

Key things to notice:

  • Scopes are the lowest-level permission units. The $XSAPPNAME prefix namespaces them to this specific application.

  • Role templates group one or more scopes. They correspond directly to the roles you had on Neo environment (the authentication-xsuaa skill maps them from web.xml).

  • Role collections are the assignable units in the SAP BTP cockpit. This is what the subaccount administrator assigns to users in Unit 4 — not the role templates directly.

The layered structure (scope → role template → role collection) is more verbose than Neo environment's flat role model, but it is what makes multi-application and cross-subaccount authorization possible on Cloud Foundry runtime.

To run the verification checks, ask your AI agent:

Code Snippet
1
Confirm the deployment is healthy — check that both modules are running, services are bound, and the application logs are clean.

Verifying the Deployment

Run the following checks to confirm the deployment itself is healthy. A full end-to-end browser test — including successful login and application access — requires role collections to be assigned to your user first. That is covered in Unit 4. The checks below confirm the infrastructure is correctly in place before moving on:

  1. Verify Modules are Running:

    Run the following command:

    Code Snippet
    1
    cf apps

    Both the Java application and the Application Router should show status running.

  2. Verify Service Bindings:

    Run the following command:

    Code Snippet
    1
    cf services

    The XSUAA service instance should show as bound to both modules — the Application Router needs it for token validation and the Java backend needs it for authorization checks.

  3. Review Application Logs:

    Check the logs for both modules to ensure there are no hidden issues:

    Code Snippet
    12
    cf logs <your-java-app> --recent cf logs <your-approuter> --recent

    Look for any startup errors, missing environment variable warnings, or service binding failures. A clean startup log indicates the migration output is correct.

Note

Full Verification: Full application access is verified in Unit 5 once trust, roles, and user assignments have been migrated in Unit 4. At that point, you will open the Application Router URL in a browser, authenticate, and confirm the application loads correctly end-to-end.

Summary

  • Before deploying, confirm that your Cloud Foundry CLI session is active and that all required service entitlements are provisioned in your Cloud Foundry CLI space.

  • The application is built and deployed with mvn clean package -DskipTests followed by cf deploy . -f, which reads mtad.yaml directly and handles build and deployment in a single step.

  • A successful migration results in two running modules in your Cloud Foundry CLI space: the Java backend and the Application Router. This two-application structure is a fundamental difference from Neo environment, where a single WAR handled everything including authentication.

    • The mtad.yaml declares both modules and all Cloud Foundry CLI service bindings.

    • The xs-security.json defines the XSUAA scopes, role templates, and role collections that replace Neo environment's flat role model.

  • End users access the application through the Application Router's route. The Application Router handles the XSUAA token exchange and forwards authenticated requests to the Java backend.

  • Verify the deployment by confirming both modules are running, services are bound, and application logs are clean.

  • Full end-to-end browser verification — authentication, role-based access, and application functionality — requires role collections to be assigned in Unit 4 and is completed in Unit 5.