【问题标题】:Error while working with Multi Tenant SAP Cloud Platform application使用多租户 SAP Cloud Platform 应用程序时出错
【发布时间】:2018-01-24 14:55:16
【问题描述】:

我正在使用 SAP Cloud Platform 中的多租户应用程序。获取租户详细信息时出现错误:

java.lang.ClassCastException:无法转换类 com.sap.cloud.account.impl.TenantContextImpl 到接口 com.sap.cloud.account.TenantContext(找到匹配接口 com.sap.cloud.account 加载的 com.sap.cloud.account.TenantContext

导致问题的代码:

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;        
}
}

我正在“ODataJPAServiceFactory”类实现中调用此调用的一个实例。

需要注意的是,我创建了一个简单的 JSP 应用程序,并且相同的代码可以正常工作。

【问题讨论】:

  • Ich arbeite zur Zeit ebenfalls 是一个更好的多租户 SAP 云平台应用程序和 Java Servlet hierzu。 Eingebunden habe Ich das über die .WAR Datei in die SCP: Ich bekomme jedoch immer den Statuscode 500 wenn ich diese codezeile verwende : TenantContext tenantContext = (TenantContext) ctx.lookup("java:comp/env/TenantContext");
  • Vielleich haben Sie eine Idee woran das liegen kann.

标签: java jpa odata sap-cloud-platform


【解决方案1】:

解决了这个问题。我将运行时从 Java Web 更改为 Java EE 6 Web Profile。看起来该 API 在 Java Web 中不可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-04-24
    • 1970-01-01
    • 1970-01-01
    • 2015-01-09
    • 1970-01-01
    • 2021-12-07
    • 2018-08-29
    相关资源
    最近更新 更多