尽管使用了解决方法,但租户不可用异常
Tenant Not availalbe exception despite the use of the workaround
我已经实现了 GetAllBusinessPartnerCommand 并且还自定义了 BusinessPartnerServlet 中的代码。当我尝试使用自定义代码调用应用程序时,总是出现此错误。
代码 GetAllBusinessPartnersCommand
package com.sap.cloud.s4hana.examples.commands;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import com.sap.cloud.s4hana.examples.BusinessPartnerServlet;
import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory;
import com.sap.cloud.sdk.frameworks.hystrix.HystrixUtil;
import com.sap.cloud.sdk.s4hana.connectivity.ErpCommand;
import com.sap.cloud.sdk.s4hana.datamodel.odata.helper.Order;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner;
import com.sap.cloud.sdk.s4hana.datamodel.odata.services.DefaultBusinessPartnerService;
public class GetAllBusinessPartnersCommand extends ErpCommand<List<BusinessPartner>>{
private static final Logger logger = CloudLoggerFactory.getLogger(BusinessPartnerServlet.class);
public static final String CATEGORY_PERSON ="1";
public GetAllBusinessPartnersCommand() {
super(HystrixUtil.getDefaultErpCommandSetter(
GetAllBusinessPartnersCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));
}
@Override
protected List<BusinessPartner> run() throws Exception {
// TODO Auto-generated method stub
return new DefaultBusinessPartnerService().getAllBusinessPartner()
.select(BusinessPartner.BUSINESS_PARTNER,
BusinessPartner.LAST_NAME,
BusinessPartner.FIRST_NAME,
BusinessPartner.IS_MALE,
BusinessPartner.IS_FEMALE,
BusinessPartner.CREATION_DATE)
.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_PERSON))
.orderBy(BusinessPartner.LAST_NAME, Order.ASC)
.execute();
}
@Override
protected List<BusinessPartner> getFallback() {
logger.warn("Fallback called because of exception:",
getExecutionException());
return Collections.emptyList();
}
}
n 您可以在下面看到问题集 ALLOW_MOCKED_AUTH_HEADER=true 的命令和提供的解决方法。在测试之前,我检查了所有变量是否设置正确并再次设置 ALLOW_MOCKED_AUTH_HEADER=true 因为我之前设置得太早了。
完成这些步骤后,我像往常一样构建我的项目,并在我调用服务时从上面得到错误。我还阅读了这个 post,其中有人遇到同样的问题并使用了上述解决方法。但这对我不起作用,我不知道为什么。
error when call page
Starting mock-server
set variables and workaround plus check
很遗憾,SAP Cloud SDK 2.x
不再受支持。请使用我们的 migration guide to move to the latest version 3.43.0
You can find my blog post on this topic too. If you face any issues, please create another Whosebug question (with tag sap-cloud-sdk
) or comment to the blog post. For more details, please find our documentation.
我已经实现了 GetAllBusinessPartnerCommand 并且还自定义了 BusinessPartnerServlet 中的代码。当我尝试使用自定义代码调用应用程序时,总是出现此错误。
代码 GetAllBusinessPartnersCommand
package com.sap.cloud.s4hana.examples.commands;
import java.util.Collections;
import java.util.List;
import org.slf4j.Logger;
import com.sap.cloud.s4hana.examples.BusinessPartnerServlet;
import com.sap.cloud.sdk.cloudplatform.logging.CloudLoggerFactory;
import com.sap.cloud.sdk.frameworks.hystrix.HystrixUtil;
import com.sap.cloud.sdk.s4hana.connectivity.ErpCommand;
import com.sap.cloud.sdk.s4hana.datamodel.odata.helper.Order;
import com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.businesspartner.BusinessPartner;
import com.sap.cloud.sdk.s4hana.datamodel.odata.services.DefaultBusinessPartnerService;
public class GetAllBusinessPartnersCommand extends ErpCommand<List<BusinessPartner>>{
private static final Logger logger = CloudLoggerFactory.getLogger(BusinessPartnerServlet.class);
public static final String CATEGORY_PERSON ="1";
public GetAllBusinessPartnersCommand() {
super(HystrixUtil.getDefaultErpCommandSetter(
GetAllBusinessPartnersCommand.class,
HystrixUtil.getDefaultErpCommandProperties().withExecutionTimeoutInMilliseconds(10000)));
}
@Override
protected List<BusinessPartner> run() throws Exception {
// TODO Auto-generated method stub
return new DefaultBusinessPartnerService().getAllBusinessPartner()
.select(BusinessPartner.BUSINESS_PARTNER,
BusinessPartner.LAST_NAME,
BusinessPartner.FIRST_NAME,
BusinessPartner.IS_MALE,
BusinessPartner.IS_FEMALE,
BusinessPartner.CREATION_DATE)
.filter(BusinessPartner.BUSINESS_PARTNER_CATEGORY.eq(CATEGORY_PERSON))
.orderBy(BusinessPartner.LAST_NAME, Order.ASC)
.execute();
}
@Override
protected List<BusinessPartner> getFallback() {
logger.warn("Fallback called because of exception:",
getExecutionException());
return Collections.emptyList();
}
}
n 您可以在下面看到问题集 ALLOW_MOCKED_AUTH_HEADER=true 的命令和提供的解决方法。在测试之前,我检查了所有变量是否设置正确并再次设置 ALLOW_MOCKED_AUTH_HEADER=true 因为我之前设置得太早了。
完成这些步骤后,我像往常一样构建我的项目,并在我调用服务时从上面得到错误。我还阅读了这个 post,其中有人遇到同样的问题并使用了上述解决方法。但这对我不起作用,我不知道为什么。
error when call page
Starting mock-server set variables and workaround plus check
很遗憾,SAP Cloud SDK 2.x
不再受支持。请使用我们的 migration guide to move to the latest version 3.43.0
You can find my blog post on this topic too. If you face any issues, please create another Whosebug question (with tag sap-cloud-sdk
) or comment to the blog post. For more details, please find our documentation.