Skip to Content
Technical Articles
Author's profile photo Showkath Ali Naseem

Upgrade to Java Spring Boot Version 2.7.x on BTP

In this blog post i would like to share my experience on upgrading Java projects , BTP CAP Java projects migration to Spring Boot 2.7.5 version

 

 

Context

If you are going to upgrade your project

  • Then this may affect maven dependencies
  • Eventually compile, build issues
  • Java application may not start/Java application deployment issues runtime issues .

 

Java developers may some tough time in fixing depended on project source code or dependencies versions , how project packaged .

Below errors may be due to inconsistency in the Spring libraries of application.

 

 Error 1

creating bean with name ‘dataSource’ defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed

 

 

Error 2 :

 

Request processing failed; nested exception is com.sap.cds.CdsDataStoreException: Error executing the statement OUT Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table “CONFIGSERVICE_LOCATIONS” not found; SQL statement:

 

Error 3 :

 

org.springframework.boot.sql.init.dependency.AnnotationDependsOnDatabaseInitializationDetector.

Error 4 :

org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerMapping]:

Factory method ‘resourceHandlerMapping’ threw exception; nested exception is java.lang.NoSuchMethodError: ‘

io.github.classgraph.ClassGraph io.github.classgraph.ClassGraph.acceptPaths(j

 

Error 5 :

Request processing failed; nested exception is com.sap.cds.CdsDataStoreException:
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table “x” not found; SQL statement:
Caused by: com.sap.cds.CdsDataStoreException: Error executing the statement
OUT at org.h2.message.DbException.getJdbcSQLException(DbException.java:453) ~[h2-1.4.200.jar:1.4.200]
OUT at org.h2.message.DbException.getJdbcSQLException(DbException.java:429) ~[h2-1.4.200.jar:1.4.200]
OUT at com.sap.cds.impl.JDBCClient.lambda$executeQuery$5(JDBCClient.java:262) ~[cds4j-runtime-1.33.0.jar:na]
OUT com.sap.cloud.sdk.cloudplatform.exception.ShouldNotHappenException:
com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: org.springframework.web.util.NestedServletException:

Error 6 :

 

Caused by: com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: org.springframework.web.util.NestedServletException: Handler dispatch failed; nested exception is java.lang.NoClassDefFoundError: com/sap/cloud/security/servlet/MDCHelper

class com.sap.cloud.security.token.XsuaaToken does not define or inherit an implementation of the resolved method ‘abstract java.util.Set getAudiences()’ of interface com.sap.cloud.security.token
… .. etc

 

Troubleshoot : Discovering the root causes of problems

 

  • If your application failed to start or unsuccessful deployment java app , then try to find Deployment errors locally by running  java app
mvn spring-boot:run
  • For BTP Cloud Foundry Java (Native Deployment Manifest.yml based ) , If deployment failed on BTP then you can Download Java Deployment logs using below command &  examine the potential errors
cf logs --recent yourjava-app-name
  • if Java project is one of module in MTA then you can refer below article

How to Download MTA Deployment Logs from SAP Business Technology Platform Cloud Foundry Environment

 

Solution

If your facing Deployment errors  or Spring Boot APPLICATION FAILED TO START

  • Please check that you consistently use Spring Boot 2.7.5 for all Spring Boot Modules and that you also included the correct Spring Framework version that is expected to be used by Spring Boot 2.7.5
  • Try to have all of these dependencies managed by the Spring Boot BOM and not maintain yourself.
  • Java Developers needs to analyse the dependency tree for project using commands or Eclipse IDE

Maven

For maven based projects you can get the list of dependent libraries by calling & then you can examine the potential version conflicts

mvn dependency:tree

or

mvn dependency:tree -Dincludes= org.springframework.*

  • Then fix versions . For example Spring Boot 7.5uses Spring Security 5.7.4 but application may have older version of Spring dependencies loaded form other dependencies (example : outdated SAP Cloud SDK bom downgraded the spring dependency to version 5.3.9. but spring-boot 2.7.5 requires a newer spring version. )
  • SAP also released the correspondingNotes

Please take a look inside the important-changes-in-java,    CAP release notes and the Spring Boot release notes where a solution for this exact issue is already mentioned.

  • Fixing dependencies issues will most likely resolve the Spring Boot start-up issues & migration issues

Always take a look at the release notes for all versions in between, as there might be important information in CAP release notes and the Spring Boot release notes

Topic2 : BTP Cloud Foundry Java Spring Services/REST API’s are not Loading Data from HANA Database , SQL Errors

 

If your Java apps connectivity to the HANA Cloud Database is broken & Deployment may fail

This issue is could be due to profile issues then solution is you have not maintain Active ProfileSpring Boot, default profile is set to default, you can set the profile via spring.profiles.active property.

 

In the spring boot application, there are several ways to set profiles (dev, uat, prod, etc.)

Few options are as follows

 

  • If you are using YML,then add below line

 

spring:

  config.activate.on-profile: cloud
  • If you are using properties file

 

spring.profiles.active=cloud

 

  • If it is SAP BTP Cloud Foundry Java Project

Then in manifest.yml file add below line under env

 

manifest.yml

 

env:

    SPRING_PROFILES_ACTIVE: cloud

    #For custom profile

    #JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{ enabled: false }'

 

After Deployment of APP , you can see new variable added in SAP  BTP user-provided variables

In your BTP Space of Java application

 

Or

you can also try to directly maintain

SPRING_PROFILES_ACTIVE  property in BTP Cockpit in your APP Space

Maintaining Active Profile over BTP Cockpit is quick fix

However, recommendation solution is to maintain spring active profile In source code

 

Thank you for reading this blog post. If you find this material useful or if you have any better suggestion to developers please leave your suggestions , feedback in the comments section below this may help Java Community on BTP

Feel free to also ‘Like’ ,‘Share’ , ‘Follow’ me to get new updates.

 

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.