Skip to Content

Multi tenant in SAP Cloud Platform

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Aug 15, 2017 at 05:24 PM

    Hi Thanu,

    Please look at our help documentation.



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

    Add comment
    10|10000 characters needed 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 to interface (found matching interface loaded by
      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;        
  • Aug 17, 2017 at 01:12 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded