SAP Cloud Platformでマルチテナントアプリケーションを使用しています。テナントの詳細をフェッチするとき、私はエラーを取得しています:マルチテナントSAP Cloud Platformアプリケーションでの作業中のエラー
とjava.lang.ClassCastException: com.sap.cloud.account.TenantContextをインタフェースするcom.sap.cloud.account.impl.TenantContextImplクラス をキャストすることはできません
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; } }
私はC午前:問題の原因com.sap.cloud.account
コードによってロードされた(見つけ一致インターフェース com.sap.cloud.account.TenantContextこの呼び出しのインスタンスを "ODataJPAServiceFactory
"クラスの実装で処理します。
私は単純なJSPアプリケーションを作成し、同じコードが正しく動作していることに注意してください。