Skip to Content
0

Multi tenant in SAP Cloud Platform

Aug 15, 2017 at 10:22 AM

128

avatar image

I have created a Java ( JPA ) application which isolates data of different customers using the tenant id. I am aware that a schema based isolation and DB based isolation is also possible. How to enable this in the backend? Is there some sample/tutorial on this?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Jin Wong
Aug 15, 2017 at 05:24 PM
0

Hi Thanu,

Please look at our help documentation.

https://help.sap.com/viewer/65de2977205c403bbc107264b8eccf4b/Cloud/en-US/54a76156cd114e5d928642b8dde47b91.html

Thanks,

Jin

If this question is answered from your perspective, then please clicked on the “Accept” link to complete this question.

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Jin,

Thank you for the information.While using the API I am getting an error when fetching the tenant details. I am calling an instance of this call in an "ODataJPAServiceFactory" class implementation.

java.lang.ClassCastException: Cannot cast class com.sap.cloud.account.impl.TenantContextImpl to interface com.sap.cloud.account.TenantContext (found matching interface com.sap.cloud.account.TenantContext loaded by com.sap.cloud.account

public class TenantContextManager
{

public TenantContextManager() {
    // TODO Auto-generated constructor stub
}

public String getCurrentAccountId() throws ServletException {
    String currentAccountId;        
    try {
        InitialContext ctx = new InitialContext();
        TenantContext tenantctx = (TenantContext) ctx.lookup("java:comp/env/TenantContext");                

        currentAccountId = tenantctx.getTenant().getAccount().getId();                  

    } catch (Exception e) {
        throw new RuntimeException(e);
    }               
    return currentAccountId;        
}
}

0
Thanu Kumaraswamy Aug 17, 2017 at 01:12 PM
0

Solved the issue. I changed the runtime from Java Web to Java EE 6 Web Profile. Looks like the API is not available in Java Web.

Share
10 |10000 characters needed characters left characters exceeded