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/. 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. Since updating to 2.0.0, the destination can't be used anymore due to the following exception:
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. There seems to be a problem with the ErpConfigContext. Since 2.0.0, the Destination has to be configured with an ErpConfigContext instead of an ErpEndpoint. 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.
Additionally, using the ErpConfigContext worked with the same coding when using 1.9.4, so the problem seems to be the update to 2.x.x. Updating to 2.1.0 also didn't solve the problem.
I've ran into this problem with several OData Services.
Is there any solution for this problem other than waiting for new SDK updates?
Do you maybe initialize the ErpConfigContext
in the servlet's constructor?
Can you try to invoke new ErpConfigContext("...")
within the servlet's doGet()
method instead? The issue here may be that the initialization of the RequestContext
only happens in the filter chain of the servlet.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With