Developing multitenant applications on SAP CP-Project Setup Part-3
As explained in the previous blog, the multi-tenant application will be deployed and run in the provider account (see section below highlighted in red).
Robert from ITeLo Consulting is the administrator of this account so he will perform the following steps in order to setup the application in the ITeLO Consulting (Provider) account.
Step 1: Create an application archive that contains all the application artifacts
Step 2: Deploy the application archive into the ITeLO Consulting (Provider) account
Step 3: Create subscriptions from consumers ABC PetroCorp and XYZ EnergyCorp to the applications running in the provider account
Let’s look at these steps in detail.
Pre-requisites:
- You have Java 8 installed.
- You have Eclipse Neon with SAP CP tools/plugins installed.
- You have the latest version of SAP CP Java Web Tomcat 8 SDK downloaded and unzipped.
- You have downloaded and set up an MTA Archive Builder Tool.
- Note that this series requires creation of multiple SAP CP accounts and therefore cannot be done using the developer trial account.
- You have an SAP CP account which has a database assigned to it. For this blog series, we expect the display name of the SAP CP account to be ITeLO Consulting (Provider).
- The ITeLO Consulting (Provider) account has at least one unused Java Compute Unit assigned to itself from the quota.
Note: You could refer to the Getting Started with SAP CP tutorials for more information.
Note: In this blog, we make use of the feature called Solutions deployment.
As an alternative, you could also just do a deployment of individual applications instead of using the Solutions feature.
Step 1: Create an application archive that contains all the application artifacts
For this blog series, the source code for the Pollution Monitoring application has been shared in GitHub. We will first clone the application source code and then create the application archive from the source code.
Clone the source code from GitHub repository
Step | Screenshot |
---|---|
a) Clone this Git repository and import the project into the Eclipse workspace. Note: The pre-requisite for this step is that EGit Plugin must be installed in Eclipse. |
|
b) After a successful import, the Project Structure should look like this | ![]() |
A real world application comprises of multiple modules developed using different technologies. The modules would also need to be deployed to different target runtimes (e.g. Java, HTML5). Instead of creating, deploying and managing these modules individually, SAP CP supports creation of a single Multi-Target Application that packages all these heterogeneous modules into a single archive.
As explained in the architecture overview from the previous blog , the business logic is defined in the Java application and UI logic is defined in an HTML5 application. In this step, Robert will build a multi-target application (MTA) Archive file in order to package the application into a deployable format.
Create (multi-target) application archive
In order to create multi-target application archive you need to download mta.jar and set up MTA archive builder as explained in the pre-requisites.
Step | Screenshot |
---|---|
a) Modules of the multi-target application are described in the MTA development descriptor fie (mta.yaml). Open this yaml file that is present under root folder of project. | ![]() |
b) The yaml file contains information about the Java and HTML5 modules that should be created. (We’ll provide more details in the MTAR Explanation section at the end of the blog).For now, bind the database (using the database ID) to the Java application.
Here, the id is the DB identifier (ID) of the database assigned to the provider account. Refer to the DB ID under the Persistence -> Databases Systems tab in the ITeLO Consulting (Provider) account. |
|
c) Navigate to the root folder of the Application and execute ‘java -jar [path to mta.jar] –build-target=NEO build command. | ![]() |
d) After a successful build, the Multi-Target application archive file (pollutionmonitoring.mtar) would be generated under the target folder as shown the snapshot. |
|
g) The pollutionmonitoring.mtar (MTA Archive) file would be generated under the target folder as shown the snapshot. | ![]() |
Step 2: Deploy the application archive into the ITeLO Consulting (Provider) account
The next step is to deploy the pollutionmonitoring.mtar MTA Archive file into the ITeLO Consulting (Provider) account. This is done using the Solutions feature shown in the SAP CP Cockpit as described here.
Step | Screenshot |
---|---|
a) Click on the Solutions tab in the SAP CP cockpit b) Click on the Deploy button. |
![]() |
c) In the Browse button of the Deploy dialog, select the MTAR file location that was generated from the Maven build. d) Choose Deploy. |
![]() |
e) Once the MTA archive file is successfully deployed, you can observe the following in the SAP CP cockpit.
|
|
Step 3: Create subscriptions from consumers ABC PetroCorp and XYZ EnergyCorp to the applications running in the provider account
In this step, Robert would create 2 consumer accounts – by name ABC Petro Corp (Consumer) and XYZ Energy Corp (Consumer).
Create consumer accounts
Step | Screenshot |
---|---|
a) Navigate to the Overview tab of the SAP CP account. b) Click on the ‘New Account’ button as shown in the screenshot. |
![]() |
c) Create an account by the name “ABC Petro Corp (Consumer)” d) Click on Save. e) Similarly, create the account “XYZ Energy Corp (Consumer)”. |
![]() |
f) From the overview pane for the global account, there would be 3 accounts shown | ![]() |
As the next step, Robert will subscribe these consumer accounts to the Java and HTML5 applications running on the provider account.
Create subscriptions to the applications running in the provider account
Step | Screenshot | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Note:A prerequisite for executing neo commands is setting up the console client. a) Using the neo console client, a subscription is created from the ABC Petro Corp (Consumer) account to the pollutionmonitoring Java application running in the ITeLO Consulting (Provider) account. neo subscribe –account <<ABC_PetroCorp_consumer_account_id>> -application <<ITeLO_consulting_provider_account_id>>:pollutionmonitoring -user <<your_user_id>> -host <<your_landscape_host>>
|
|
||||||||||
b) Similarly a subscription has to be created to the pollutionmonitoringui HTML5 application in the ITeLO Consulting (Provider). Click on the Subscriptions tab, then select “New Subscription” |
![]() |
||||||||||
c) Select the provider account and application as shown in the screenshot. d) Then click on Save. e) This would create a subscription to the HTML5 application. |
![]() |
||||||||||
f) In the Subscriptions tab of ABC PetroCorp(Consumer) account, you would see the following subscriptions. | ![]() |
||||||||||
g) Similarly, subscriptions have to be created for XYZ Energy Corp (Consumer) as summarized in the table. |
|
MTAR Explanation
Now let’s understand how the MTAR was created in Step 2. The required configuration was specified in the file – the MTA Development descriptor file (mta.yaml)
.MTA Development Descriptor file: Modules of the multi-target application are described in the MTA deployment descriptor file (mta.yaml).
- HTML5 module is defined below by specifying the module name, type and dependency (to the Java application that contains the business logic).
- Java module is defined below by specifying the module name, type and dependency (to the database service that will persist data generated by the Java application).
- SAP CP persistence service is configured with the ID of the database that is assigned to the SAP CP account.
Hi guys, great blog series. In the Itelo case, a Java multitenant application is used, but would this architecture also be valid for MTA's running on the Cloud Foundry based runtimes as well? So for instance NodeJs?
Kind regards,
Jeroen
Hi Jansen,
We are preparing a blog series for CF based runtimes. Will update you shortly.
Regards,
Hari
Dear Hari,
any update of the blog series regarding Cloud Foundry?
Best regards
Gregor
Dear Gregor,
Sorry for keeping you wait.. There has been a lot of developments. We wanted to blog it with the best of all. 🙂 Few more waits..
Regards,
Hari
Hi Hari,
just stumbled across this great blog. When do you think the waiting time on the CF bolgs is over 😉
kind regards
Oliver
Hi Oliver,
My bad! Didnt cross reference it here. Here is the blog.
Regards,
Hari
thanks! Great Blog!
Hi Ashitha,
thank you for this introduction into the creation of Multi-Tennant Applications in SAP CP.
I would suggest that you update the neo subscribe command. When using the full parameter names you need two dashes (--) instead of just one (-). Perhaps you update the formatting and use a code sample like:
Best regards
Gregor
Hi Ashitha MS,
I am stuck on the application archive creation process.
This returns error:
I've tried all 4 different versions of the archive builder available on the support portal with the same result.
My mta.yaml:
Why am I getting this error?
Any help is much appreciated.
Thanks
Peter
I managed to solve by removing the parent section from my parent pom.xml:
Cheers
Peter
Hello Peter,
I have exactly the same issue as you have described.
After removing the parent section from pom, I was able to build it successfully.
However, using java -jar mta.jar -build-target=NEO build still leads to the issue "ERROR: Failed to build module “pollutionmonitoring-java”. Command execution failed"
Can you remember if you have adjusted something else?
Kind regards
Oliver
Hi Oliver,
that's the only pom descriptor change I've done. You need to make sure you've installed Maven and included it in your system path environment.
Also be careful about the number of dashes you put in front build-target command. I think it needs to be 2 dashes like this:
Peter
Hi,
Is it possible to ignore the 'id' from resources such that it can use whichever database is there by default? Or, can we specify that a new database should be created under the same id if it doesn't exist?
Hi,
Do we have reference for creating cloud foundry java multi-tenant microservice using hana-hdi (instance Manager) to achieve schema level separation for tenant.
Best Regards,
Vijendra
Hi There,
First thanks very much for the great blog.
I have a question, would it be possible to do the multi-tenant approach on neo for a fiori launchpad with UI5 apps? No java involved as in your example above?