SAP S/4HANA Cloud SDK: Version 2.9.0 is Available
The new version of the SAP S/4HANA Cloud SDK Java libraries is available since today. You can update your dependencies to version 2.9.0 and consume the new version from Maven Central.
In this blog post, we will walk you through the highlights of these releases. For a complete overview, visit our release notes for the Java libraries. The release notes also include the change log of all our releases so far.
At the end of the article, you will find a set of instructions on how to update to the new version.
Java Libraries: Release Highlights
Reduce memory consumption
We have identified means to reduce the memory consumption of JavaEE projects that use the Java virtual data model (VDM) of the SAP S/4HANA Cloud SDK. As a result, projects created freshly with one of the JavaEE archetypes (
scp-neo-javaee7) will out-of-the-box include a
beans.xml file that ensures that the CDI scanner does not search for beans in
*.odata.namespaces.* packages of the VDM. This strongly reduces the required memory (especially, metaspace) of the application. Dependency injection of VDM services will still work because they are located in a different package.
For any existing projects based on JavaEE, we recommend to do the following.
If you do not yet have a
beans.xml file, create this file in the folder
application/src/main/webapp/WEB-INF with the following content:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" bean-discovery-mode="annotated"> <scan> <!-- do not scan namespaces since CDI is only required for service classes --> <exclude name="com.sap.cloud.sdk.s4hana.datamodel.odata.namespaces.**"/> </scan> </beans>
If your project already includes such a
beans.xml file, add the scan exclusion manually.
Comparison of the heap memory consumption in a basic project shows that memory consumption by the CDI bean manager has been reduced by 95%, or more than 100 MB. Startup times have also improved significantly, as well as the amount of additional memory used at startup. As a consequence, we have removed the Java metaspace size configuration from
manifest.yml files generated by the archetypes, because the default will work fine after applying above mentioned changes.
All entity classes now provide a new method
attachToService that allows setting the OData service path and
ErpConfigContext after creating an entity manually. Both parameters are optional and set to the default values if not provided. A thus configured entity can be used to issue calls to the backend system such as fetching associated entities:
entity = BusinessPartner.builder().businessPartner("1").build(); entity.attachToService(null, null); entity.fetchBusinessPartnerAddress();
We have updated the
scp-cf-tomee archetype to use Apache TomEE 7.0 (Web Profile), instead of 1.7. TomEE 7 targets JavaEE 7 (instead of JavaEE 6). In detail, we have adapted the
manifest.yml to use the
tomee7 runtime on SAP Cloud Platform, Cloud Foundry, and changed the TomEE Maven Plugin for local execution to 7.0.5.
Projects created with the
scp-cf-spring archetype now include hints how to setup security with the programmatic approach in Spring Boot. Those hints come as commented-out sections of required dependencies in the
pom.xml and a sample
SecurityConfig class. Additionally, we now manage
spring-security-oauth2 in the SDK’s bill of material (BOM).
UserFacade now offer an additional method
tryGetCurrentUser which returns a
Try for the current user, similar to what is already available for tenants. This
Try object contains the current user (possibly
null) or any possibly thrown exception. This allows to write idiomatic code without try-catch-blocks. For more details on this monadic container type, refer to the Vavr user guide.
Several further improvements are listed in the full release notes.
Please note that several APIs of SAP S/4HANA Cloud have been updated in the SAP API Business Hub to properly reflect the operations that are supported by the respective OData service. As a consequence, several operations have been removed from the Java virtual data model (VDM), as they were never supported by the OData service. For a detailed list of the affected operations, take a look at the compatibility notes of the release notes.
How to Update: Java libraries
To update the version of the SAP S/4HANA Cloud SDK Java libraries used in an existing project, proceed as follows:
- Open the pom.xml file in the root folder of your project.
- Locate the dependency management section and therein the
- Update the version of that dependency to
With this, you are already done thanks to the “bill of material” (BOM) approach. Your dependency should look like this:
<dependencyManagement> <dependencies> <dependency> <groupId>com.sap.cloud.s4hana</groupId> <artifactId>sdk-bom</artifactId> <version>2.9.0</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> <!-- possibly further managed dependencies ... --> </dependencyManagement>
You can now recompile your project (be aware of the compatibility notes, though) and leverage the new features of the SAP S/4HANA Cloud SDK in version 2.9.0.