简体   繁体   English

使用S / 4HANA Cloud SDK> = 2.0.0执行OData查询时的DestinationAccessException

[英]DestinationAccessException while executing OData Query with S/4HANA Cloud SDK >= 2.0.0

I'm trying to read data with an OData Service out of an S/4HANA Cloud 1805 system using the VDM as described in https://blogs.sap.com/2017/05/21/step-4-with-sap-s4hana-cloud-sdk-calling-an-odata-service/ . 我正在尝试使用VDM从使用VDM的S / 4HANA Cloud 1805系统读取数据,如https://blogs.sap.com/2017/05/21/step-4-with-sap-中所述s4hana-cloud-sdk-calling-an-odata-service / The Destination uses Basic Authentication. 目标使用基本身份验证。

Sample call: 示例电话:

final ErpConfigContext context = new ErpConfigContext("...");
return new DefaultQualityInspectionDataService().getAllInspectionLot().select(...).execute(context);

This worked at least until the S/4HANA Cloud SDK release 1.9.4. 这至少在S / 4HANA Cloud SDK版本1.9.4之前有效。 Since updating to 2.0.0, the destination can't be used anymore due to the following exception: 由于更新到2.0.0,由于以下异常,目标无法再使用:

2018 06 18 12:43:55#+00#ERROR#org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/app-application].[com.sap.cloud...Servlet]##anonymous#https-jsse-nio-8041-exec-3#na#a078260ed#app#web#a078260ed#na#na#na#na#Allocate exception for servlet [com.sap.cloud...Servlet] com.sap.cloud.sdk.cloudplatform.connectivity.exception.DestinationAccessException: Failed to get ConnectivityConfiguration: no RequestContext available. Have you correctly configured a RequestContextFactory or have you wrapped your logic in a RequestContextExecutor when executing background tasks that are not triggered by a request?
at com.sap.cloud.sdk.cloudplatform.connectivity.ScpNeoDestinationFacade.getConnectivityConfiguration(ScpNeoDestinationFacade.java:60)
at com.sap.cloud.sdk.cloudplatform.connectivity.ScpNeoDestinationFacade.getDestinationConfiguration(ScpNeoDestinationFacade.java:108)
at com.sap.cloud.sdk.cloudplatform.connectivity.ScpNeoDestinationFacade.getGenericDestination(ScpNeoDestinationFacade.java:183)
at com.sap.cloud.sdk.cloudplatform.connectivity.DestinationAccessor.getGenericDestination(DestinationAccessor.java:136)
at com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext.<init>(ErpConfigContext.java:218)
at com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext.<init>(ErpConfigContext.java:367)
at com.sap.cloud.sdk.s4hana.connectivity.ErpConfigContext.<init>(ErpConfigContext.java:442)
at com.sap.cloud...Servlet.<init>(...Servlet.java:31)
...
at java.lang.Thread.run(Thread.java:808)

The exception occurs immediately when the HTTP servlet is called, even if the Destination isn't used yet. 调用HTTP Servlet时会立即发生异常,即使尚未使用Destination也是如此。 There seems to be a problem with the ErpConfigContext. ErpConfigContext似乎有问题。 Since 2.0.0, the Destination has to be configured with an ErpConfigContext instead of an ErpEndpoint. 从2.0.0开始,必须使用ErpConfigContext而不是ErpEndpoint配置Destination。 I have read the migration guide ( https://blogs.sap.com/2018/06/05/migration-guide-moving-to-version-2.0.0-of-the-sap-s4hana-cloud-sdk/ ) regarding the ErpConfigContext and RequestContext Handling, but the solution isn't applicable in my application since i never had to use a RequestContextListener and it worked nevertheless. 我已阅读迁移指南( https://blogs.sap.com/2018/06/05/migration-guide-moving-to-version-2.0.0-of-the-sap-s4hana-cloud-sdk/ )关于ErpConfigContext和RequestContext Handling,但该解决方案不适用于我的应用程序,因为我从来没有使用RequestContextListener,但它仍然有用。

Additionally, using the ErpConfigContext worked with the same coding when using 1.9.4, so the problem seems to be the update to 2.xx Updating to 2.1.0 also didn't solve the problem. 另外,在使用1.9.4时,使用ErpConfigContext使用相同的编码,因此问题似乎是更新到2.xx更新到2.1.0也没有解决问题。

I've ran into this problem with several OData Services. 我用几个OData服务遇到了这个问题。

Is there any solution for this problem other than waiting for new SDK updates? 除了等待新的SDK更新之外,还有解决此问题的方法吗?

Do you maybe initialize the ErpConfigContext in the servlet's constructor? 你可能在servlet的构造函数中初始化ErpConfigContext吗? Can you try to invoke new ErpConfigContext("...") within the servlet's doGet() method instead? 您可以尝试在servlet的doGet()方法中调用new ErpConfigContext("...")吗? The issue here may be that the initialization of the RequestContext only happens in the filter chain of the servlet. 这里的问题可能是RequestContext的初始化只发生在servlet的过滤器链中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM