【发布时间】: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