Adaptation Required for Deprecated ScpCfDestination Methods in SAP Cloud SDK Upgrade (v4.28.0 to v5.13.0)
Issue Description
Hi Colleagues,
We are in the phase of upgrading the SAP cloud sdk version from 4.28.0 to 5.13.0.
However in the process, we noticed that after upgrading the version, the dependency com.sap.cloud.sdk.cloudplatform:scp-cf, as shown below, is now deprecated and is to be moved to com.sap.cloud.sdk:sdk-core:
Hence, we did that but then the classed pertaining to the following imports was no longer supported:
• ScpCfDestination
• ScpCfDestinationLoader
• ScpCfDestinationOptionsAugmenter
• ScpCfDestinationRetrievalStrategy
Hence, as suggested in the migration guide, we imported the relevant classes and made relevant changes.
We have a class ‘S4Destination’ which is designed to retrieve the destination information required to connect to SAP S/4HANA Cloud in a multi-tenant environment. It checks for a specific property on the destinations and ensures only one valid destination is configured, and returns an HttpDestination for communication.
However, at one of the places in our code, as shown below, we were using the method getName() of the ScpCfDestination class to retrieve the destination name from an object of the type ScpCfDestination.
Please refer the entire code from here.
Now, after replacing the ScpCfDestination with the new Destination implementation, we see that this method is no more available with the new implementation and its extension class which is DestinationProperties.
Hence, can you please help us adapt this logic with the new Destination class provided?
Important information:
- Your code : Destination class
Impact / Priority
We are in the phase of upgrading our CAP version to 3.2.0 in a month and hence need to migrate to sdk version 5 as a preparatory step which is a blocker for us now.
Project Details
The main repo of our project as well as the sub-domain Resource Request where this code for destination resides:
- For Resource Management umbrella module : https://github.tools.sap/Cloud4RM/Resource-Management
- For pom file with the version we are migrating from : https://github.tools.sap/Cloud4RM/Resource-Request/blob/master/project-integration-adapter/pom.xml#L16
- For Resource Request module : https://github.tools.sap/Cloud4RM/Resource-Request
- SDK Version:
4.28.0
- Link to GitHub repo: https://github.tools.sap/Cloud4RM/Resource-Management
- Project type, for example:
- [x] CAP Project
- [ ] SDK Maven Archetype
- [ ] None of the above:
- Platform:
- [x] Cloud Foundry
- [ ] Deploy with Confidence (Cloud Foundry)
- [ ] None of the above:
we were using the method
getName()of theScpCfDestinationclass to retrieve the destination name
Please find our API:
- ScpCfDestination destination;
- String name = destination.getName();
+ Destination destination;
+ String name = destination.get("Name", String.class).getOrNull();
+ String name = (String) destination.get("Name").getOrNull(); // alternative
+ String name = destination.get(DestinationProperty.NAME).getOrNull(); // alternative
Hi @newtork,
Thank you for your response.
We were able to replace the deprecated library with this and this solved our compilation failure.
However, when we consumed the new API replacing the deprecated libraries, we found the following test failures arising due to the change.
As we tried to analyse one of the failed tests, this is the failure logs which we got: Error_log_for_sdk_version_upgrade.txt
For pom file with the version we are migrating from : https://github.tools.sap/Cloud4RM/Resource-Request/blob/master/project-integration-adapter/pom.xml#L16 One of the failing test from the Resource Request module : Failing Test Class
Can you please help us in understanding what could have been the root cause of the error and how can we fix it?
Caused by: java.lang.ExceptionInInitializerError: Exception java.lang.NoSuchFieldError: XSUAA [in thread "main"]
at com.sap.cloud.sdk.cloudplatform.connectivity.BtpServicePropertySuppliers.<clinit>(BtpServicePropertySuppliers.java:37)
Indicates a dependency version conflict.
The (missing) change was introduced in Cloud SDK 5.13.0. Please make sure to use the latest versions.
Also consider investigating for dependency conflicts: If you assume already using the latest version, then some other older Cloud SDK dependency sneaks in transitively from one of your other dependencies.
I have to agree with the colleagues at CAP. The dependency conflict for "missing field: XSUAA" is not pointing at Cloud SDK, but at the Service Binding library and whatever library repackages the code.
According to CAP migration guide min Cloud SDK version requirement is 5.9.0.
Can you please check what happens if you use SAP Cloud SDK 5.12.0 (or earlier)? Maybe the inconsistent dependencies work in this case.
Hi @newtork,
Thank you so much for the response. Got it that the issue was indeed due to a CALM library.
Thanks & Regards, Nitya