Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
One of the primary features of using the SAP WebIDE for Cloud Foundry (CF) application development is the ability to create a multi-target application (MTA) easily. An MTA is an SAP construct that allows you to combine modules into a single deployable unit for lifecycle maintenance. These modules could potentially use different runtimes (one on Node.js, one on Python, etc.). For more information on MTAs for the Cloud Foundry environment, please click here.

The Web-based SAP WebIDE, however, may not be the ideal developer environment for everyone. It does not work when you're offline and it also does not have support for development in languages such as Python, PHP, etc. Many developers prefer using their own IDE while still taking advantage of enterprise SAP features such as MTA, app router, and XSUAA. In this blog, I will show how you can use your own IDE and still build multi-target applications. It just requires a one-time setup of a few tools that are developed and fully supported by SAP Cloud Platform.

Step 1: Install the CF command line interface


You can download and install the cloud foundry command line interface (CF CLI) from the following location. There are a number of options for download on a variety of platforms and install programs.

https://github.com/cloudfoundry/cli#downloads

After a successful installation, you should be able to execute the cf command:
$ cf -v
cf version 6.33.1+c77e55743.2017-12-15

Step 2: Install the MTA Plugin for the CF CLI from SAP


SAP has developed and published an MTA plugin for Cloud Foundry CLI. This MTA plugin allows you to perform lifecycle operations like deployment and un-deployment on multi-target applications. The MTA plugin can be downloaded from SAP cloud platform tools page (search for MTA Plugin and pick your platform):

https://tools.hana.ondemand.com/#cloud

Install the MtaPlugin by running the install-plugin sub-command:
$ cf install-plugin cf-cli-mta-plugin-1.0.2-darwin-x86_64.bin 
Attention: Plugins are binaries written by potentially untrusted authors.
Install and use plugins at your own risk.
Do you want to install the plugin cf-cli-mta-plugin-1.0.2-darwin-x86_64.bin? [yN]: y
Installing plugin MtaPlugin...
OK
Plugin MtaPlugin 1.0.2 successfully installed.

Step 3: Install the MTA Archive Builder


The MTA archive builder is a standalone command-line tool that builds a deployment-ready .mtar file from an MTA project using the development descriptor (mta.yaml) file. For details on the MTA archive builder and to download the jar file, please visit the following URL. Note: You will need Java 8 on your machine in order to execute this tool.

SAP MTA Archive Builder

Save the download JAR file (e.g., MTABUILDER110_0-80002501.JAR) in a well-known location and add it to your Java classpath.

You now have all the software you need to build and deploy an MTA!

Step 4: Build and Deploy a sample MTA


If you are looking for a skeleton sample MTA project, then feel free to download one from my GitHub repository location below:

https://github.com/sunilwadhwa/mymta1.git

Mymta1 is a simple skeleton MTA project with three distinct modules - a Node.js module called approuter, a Python module called pymodule1, and a Java module called jmodule1. It also contains an xsuaa service used by the approuter for authentication. It is ready to be deployed to a CF space.

To build the MTAR file, cd to the root folder of the project and execute the MTA Archive Builder:
$ java -jar MTABUILDER110_0-80002501.JAR --build-target CF --mtar ./target/mymta1.mtar build
SAP Multitarget Application Archive Builder 1.1.2
Module "jmodule1": invoking maven
Module "pymodule1": zipping directory pymodule1
Module "approuter": invoking npm
Module "approuter": command output
...
> up to date in 0.662s
Module "approuter": zipping directory approuter
Module "jmodule1": command output
> [INFO] Scanning for projects...
...
...
> [INFO] ------------------------------------------------------------------------
> [INFO] BUILD SUCCESS
> [INFO] ------------------------------------------------------------------------
> [INFO] Total time: 0.893 s
> [INFO] Finished at: 2018-02-02T16:33:04-07:00
> [INFO] Final Memory: 15M/309M
> [INFO] ------------------------------------------------------------------------
Generating archive ./target/mymta1.mtar
Done

To deploy the generated MTAR file, run the cf deploy command:
$ cf api
api endpoint: https://api.cf.us10.hana.ondemand.com
api version: 2.99.0

$ cf deploy target/mymta1.mtar
{{output edited for clarity}}
Deploying multi-target app archive target/mymta1.mtar in org org / space dev as sunil.wadhwa01@sap.com...
Uploading 1 files...
target/mymta1.mtar
OK
Starting deployment process...
Service "mymta1-uaa" updated
Application "approuter" started and available at "..."
Application "jmodule1" started and available at "..."
Application "pymodule1" started and available at "..."
Process finished.

Step 5: Configure your IDE (Eclipse example shown below)


In this final step, I will show you how to configure an IDE like Eclipse, to build and deploy a multi-target application. You can create a new Project Builder in the Project Properties section and specify the java command that we used in the previous step.



Here is a screenshot of the MTA-Builder that I created as an example. Now, when I click on Project --> Build Project menu, the MTA is automatically built for me. In a similar way, you can create an External Tool configuration to run the deployment of the MTAR to cloud foundry.

Have fun and please comment below if you have any questions/feedback!
17 Comments
Benny
Product and Topic Expert
Product and Topic Expert
really usefull stuff! Thanks for sharing.

 
Steven_UM
Contributor
Great blog ... thanks that really helped me into getting my local HANA Express project getting deployed into CF.

I did encounter quite some issues though - like not having a node build runtime ( missing python, etc ) and getting C++ compile errors on a standard module 'fibers' ... in the end it turned out that I needed to downgrade node.js towards v6 and all problems were gone ( apparently fibers is not supporting node js +v8 - as my node version was to high it started recompiling those modules and hence all issues ).

 
0 Kudos
Thanks for the valuable feedback! Currently, the MTA sample project requires you to have many different runtimes and build programs (Node, python, and Java). I am working on providing more options, so that you can pick and choose which components you want. Follow and watch this space for more details. Thanks.
raeijpe
Contributor
Many Thanks, Helps me a lot to setup my first MTA application on CF
htammen
Active Contributor
Thanks, helped me a lot to switch from SAP Web IDE to my beloved local development environment. Although I like SAP Web IDE it's sometimes more productive to use local tools.
former_member184876
Active Participant
Able to deploy first MTA application to cloud foundry. Thank you for the great blog

Hi Sunil,

 

Thank you for the nice blog. The import from Git is successful. However, eclipse does not recognized jmodule1 as a maven project. This is crucial for testing the service. Can you please explain how to import this properly?

0 Kudos
Hi Tejas - Thanks for your feedback! This usually happens when you don't have maven installed on the command line and in your path. Can you please open up a command prompt and type the command "mvn --version"? If you don't get any output or command not found, then you will need to make sure the command is installed and in your PATH variable. Send me a PM if you have any additional problems. Thanks.
0 Kudos
Also, since you are using Eclipse, you must make sure that the path where mvn command is located must be specified in the PATH variable in the Environment section of the tool configuration. Hope this helps! Let us know how it goes.

 
MikeDoyle
Active Contributor
Thanks so much Sunil, this worked first time (!) and gave me a vital workaround for a Web IDE issue.  Now I can get back to work
former_member224482
Active Contributor
0 Kudos
SAP Multitarget Application Archive Builder 1.1.19
Module "approuter": invoking npm.cmd install --production
Module "poc201905": invoking maven
ERROR: Failed to build module "approuter". Command execution failed

What can be done to investigate the "Command execution failed" ?
0 Kudos
Robin - Check if you have node command line installed. Type the command "node --version" and you should expect to get a valid response. This is required in order to build approuter and other Node.js modules. Thanks.
former_member224482
Active Contributor
0 Kudos
After installed Node.ja, the error is :
silly fetchPackageMetaData error for @sap/approuter@2.7.1 request to https://registry.npmjs.org/@sap%2fapprouter failed, reason: connect ETIMEDOUT 172.20.5.58:8080
0 Kudos
Robin - Also, you need to tell Node Package Manager (NPM) where to find the SAP modules. In order to do that, please run the following command line:

npm config set @sap:registry https://npm.sap.com

 
former_member224482
Active Contributor
I was using : npm config set @sap.registry https://npm.sap.com
Instead of : npm config set @sap:registry https://npm.sap.com

The documentation https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/050d87a61faa4fb88f687abd7bd... should be updated.

I also had to perform :
npm config rm proxy
npm config rm https-proxy
showkath_naseem
Product and Topic Expert
Product and Topic Expert
0 Kudos
Hi @sunilw

 

Very-useful blog.

I changed mta.yaml &  tried below commands

C:\Users\xxxidxx\git\CAPWS\mymta1>java -jar "C:\mta_archive_builder.jar" --build-target CF --mtar ./target/mymta1.mtar build

then

cf push target\mymta1.mtar

I am getting below error

Pushing app target\mymta1.mtar to org SAP IT Cloud_sapitcfd / space vms-backend-cf as I311690...
Getting app info...
Updating app with these attributes...
name: target\mymta1.mtar
path: C:\Users\xxxidxx\git\CAPWS\mymta1
disk quota: 1G

None of the buildpacks detected a compatible application
Exit status 222

Error staging application: An app was not successfully detected by any available buildpack

TIP: Use 'cf buildpacks' to see a list of supported buildpacks.

please find attached buildpacks information

Note :

I have changed  mta.yaml file CF urls

ID: mymta1
_schema-version: '2.0'
version: 1.0.0

modules:
- name: approuter
type: nodejs
path: approuter
parameters:
disk-quota: 256M
memory: 256M
properties:
TENANT_HOST_PATTERN: "^(.*)api.cf.sap.hana.ondemand.com"
destinations: >
[
{"name":"jmodule1", "url":"https://api.cf.sap.hana.ondemand.com", "forwardAuthToken": true },
{"name":"pymodule1", "url":"https://api.cf.sap.hana.ondemand.com", "forwardAuthToken": true }
]
requires:
- name: mymta1-uaa

- name: jmodule1
type: java
path: jmodule1
parameters:
disk-quota: 256M
memory: 512M
build-parameters:
builder: maven
requires:
- name: mymta1-uaa

- name: pymodule1
type: python
path: pymodule1
parameters:
disk-quota: 256M
memory: 128M
command: python hello.py
requires:
- name: mymta1-uaa

resources:
- name: mymta1-uaa
type: com.sap.xs.uaa
parameters:
service: xsuaa
service-plan: application
path: config/xs-security.json

Regards,

Showkath.
former_member183031
Participant
0 Kudos

Hi Sunil,

 

Very useful, i was looking for an option where i can change the existing module name itself while deploying. once its possible, we can use same mtar in different cf spaces.

do we have such capabilites while deploying mta file.?

 

Regards,

MBR