Skip to main content

Troubleshooting SDK Java

maven central

Solving Common Problems

Tenant or Principal Not Available

Symptoms

Tenant or principal information is not available or an incorrect tenant is used.

Possible causes:

Provider Instead of Subscriber Account Used

Symptoms

Destinations are returned only for the provider account, but not for a subscriber account.

Possible causes:

Connecting to an ERP System fails

Symptoms:

The ERP system unexpectedly responds with 401: Unauthorized or 403: Forbidden.

Possible causes:

  • The SAP Client and Locale headers will be missing if the properties sap-client and sap-locale are not defined. See Connecting to SAP S/4HANA.

Compilation Failures in the Generated OData Classes

Symptoms:

Compilation fails due to missing Getters and Setters on entity objects.

Possible causes:

  • Getters and Setters will be missing if Lombok is not present in the dependency tree of your project. See Using the OData Generator.
  • Getters and Setters will be shown red if your IDE does not support Lombok. Hence, install the Lombok plugin for your IDE.

Compilation or Runtime Failures After Updating the SAP Cloud SDK Version

Symptoms:

MethodNotFound, ClassDefNotFound or similar exceptions occur.

Possible causes:

The Java App Has Good Performance on Your Local Machine but Utilizes 100% CPU on SAP Business Technology Platform, Cloud Foundry Environment

Symptoms:
  • The Java app executes multiple threads and runs with good performance on a powerful local machine.
  • The performance significantly drops after the app is deployed to SAP Business Technology Platform - Cloud Foundry and CPU utilization is always around 100%.

Possible causes:

  • A powerful developer's machine usually has much better CPU and memory capacity than a standard cloud instance.
  • SAP BTP, Cloud Foundry environment provides 1/4 of CPU unit per every GB of memory. With maximum memory per instance of 8 GB, you can get a maximum of 2 CPU cores.
  • All the limitations are subject to change. Please check the latest details about SAP BTP, Cloud Foundry Environment quotas and limitations
  • If even after achieving the maximum vertical scale of your instance, your app doesn't reach the desired performance level, try to optimize it. Consider scaling it horizontally or different custom solutions to boost performance where it lags.

No Such Method: com.google.gson.JsonParser.parseReader

Symptoms

In your application log you find exception java.lang.NoSuchMethodError: com.google.gson.JsonParser.parseReader(Lcom/google/gson/stream/JsonReader;)Lcom/google/gson/JsonElement;.

Possible causes:

  • Your project uses the GSON library in version 2.8.5 or earlier. This could happen if you do not use the SAP Cloud SDK Bill-of-Material. To solve this issue, update GSON to at least version 2.8.6.

Class Not Found: JsonEncoder

Symptoms

Your application does not start and fails with the error message "Could not create component [encoder] of type [com.sap.hcp.cf.logback.encoder.JsonEncoder] java.lang.ClassNotFoundException: com.sap.hcp.cf.logback.encoder.JsonEncoder".

Possible causes:

  • Your project uses the Logback library for application logging. The required dependency com.sap.hcp.cf.logging:cf-java-logging-support-logback is missing. To solve this issue, add this dependency to your project. Also, use the SAP Cloud SDK Bill-Of-Material in your POM to manage the version of this dependency.

OData Request Rejected by or Failed in OData Service

Symptoms

Your OData request returns with a 400 (bad request) or 500 (server error) HTTP code.

Possible causes:

java.lang.IllegalArgumentException: JClass name empty

Symptoms

While generating a type-safe API client for an OData service, you encounter the exception message "java.lang.IllegalArgumentException: JClass name empty".

Possible causes:

  • The service specification (EDMX file) contains an entity that is named Type, Type_, or just _.

    By default, both the OData V2 and V4 VDM generators use the S4HanaNamingStrategy to generate valid Java names from the given service specification. Hereby, it removes pre- and suffixes that are commonly used in SAP service specifications, such as the suffixes Type and _ for entities. In special cases, where an entity name consist of those suffixes only, that logic leads to the generation of an empty class name, which, in turn, then results in the observed exception.

    To solve that issue, you can change the naming strategy used by the generator. The SAP Cloud SDK additionally includes the com.sap.cloud.sdk.datamodel.odata.utility.SimpleNamingStrategy out-of-the-box, which does not perform any unnecessary pre- and suffix removal.

DestinationAccessException: Failed to read authentication token. The destination service responded with an error: Could not verify the provided CSRF token because your session was not found

Symptoms

When using a Destination you encounter an exception message like "DestinationAccessException: Failed to read authentication token. The destination service responded with an error: Could not verify the provided CSRF token because your session was not found".

Possible causes:

  • The Destination Service on Cloud Foundry is unable to generate an authentication token that will be used in later requests. In the service configuration, the destination entry references a token service endpoint that could not communicate correctly with the Destination Service.

    To solve that issue, please check every field in the destination configuration for valid input. Please find the official documentation from the Destination Service for more details. The value for field "Token Service URL" may require the full service endpoint path, including e.g. /oauth/token.

SSLHandshakeException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target

Symptoms

When accessing an On-Premise system from your local machine the HTTP client is unable to establish a secure connection to the target server. You may experience the follow-up error message: "ODataConnectionException: Connection was aborted."

Possible causes:

  • To validate the SSL connection your Java runtime would need to check the chain of trusted certificates. Please review your local Java trust store.

    To solve the issue there are many tutorials on how to register certificates. However, if you require a quick solution for your local development environmment, you can add a special flag to your "destinations" environment variable: "TrustAll" : "true". This will disable the certificate validation on your local runtime.

DefaultHttpClientFactory not a subtype Error

Symptoms

Applications that rely on the SAP Java Buildpack, which is always true for application that require JCo, may throw the following exception when trying to access a RFC destination:

java.util.ServiceConfigurationError: com.sap.cloud.security.client.HttpClientFactory: com.sap.cloud.security.client.DefaultHttpClientFactory not a subtype

Possible causes:

  • This issue is typically caused by a dependency scope conflict and can be solved by following our guidance.

Incoming Requests Fail Because a Request Header is Too Large

Symptoms

your app is responding with 400 codes and you see a log entry Request header is too large

Possible causes:

  • In some cases you may need to configure your app/server to accept larger request headers. Refer to this guide on how to achieve this for Spring based applications. In case you are deploying a WAR file with the SAP Java Buildpack refer to this documentation.