Spring AutoReconfiguration will be no longer installed for Spring Boot 3 applications since JBP v4.62.0
search cancel

Spring AutoReconfiguration will be no longer installed for Spring Boot 3 applications since JBP v4.62.0

book

Article ID: 297407

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

Spring AutoReconfiguration will be no longer installed for Spring Boot 3 applications since JBP v4.62.0

Resolution

Checklist:

From v4.62.0, the Java Buildpack will no longer install the  Spring AutoReconfiguration (SAR) library for Spring Boot 3 applications. This library was deprecated in May 2022 and performs overwriting of your configured Spring Beans to connect to bound services. This is not recommended for use in production environments and the recommended replacement is the Java CfEnv library.

Applications should not be affected by this change if:
 

  • They are using Spring Boot 2.x  - SAR will be installed & supported for the life of Spring Boot 2, although it is recommended to migrate to Java CfEnv as soon as possible.
  • They are using Spring Boot 3 and 
    • have already migrated from SAR to Java CfEnv* or
    • have already migrated from Spring Cloud Connectors to Java CfEnv* 

       * the buildpack will not install Java CfEnv if it is already detected as an app dependency


Your applications might be affected by the following 2 scenarios:

  1. App uses Spring Boot 3 and does not have Spring Cloud Connectors as a dependency
  2. App uses Spring Boot 3 and does have Spring Cloud Connectors as a dependency
  3.  


If your application is affected by above 2 scenarios, please see following instructions for troubleshooting. 

App uses Spring Boot 3 and does not have Spring Cloud Connectors as a dependency

First check the following set of conditions, all of which must be present:

  1. Your app is a Spring Boot 3 app
  2. You have not manually disabled SAR via the CF CLI or manifest environment variable:
    1. JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{enabled: false}'
  3. Your app is bound to a service of one of these types:
    1. Cassandra
    2. Relational Database
    3. RabbitMQ
    4. Mongo DB
    5. Redis
    6. SMTP
  4. The startup logs for the app show a log entry such as:

<bean-name> bean of type with <bean-type> reconfigured with <service-name> bean
For example: 'dataSource' bean of type with 'javax.sql.DataSource' reconfigured with 'mysql' bean


In most cases, the Java CfEnv library should replace the functionality of the Spring AutoReconfiguration library for Spring Boot 3 apps without any manual intervention. The Java CfEnv library examines bound services of the above types (except SMTP) and sets well-known Spring Boot properties so that Spring Boot's Autoconfiguration can kick-in. 


Use cases that will not be handled automatically by the switch from SAR to Java CfEnv in v4.62.0 of the buildpack and workarounds:
 

  1. Multiple Service Instances: If you need to configure connections to multiple instances of a given service type, or do anything more than setting application properties for Spring Boot to pick up and use in auto-configuration, then you must follow the manual configuration approaches laid out in the migration guide.
  2. Cloud Property Placeholders: The Spring Auto Reconfiguration module exposes a set of property placeholder values that you can use to access values from VCAP_SERVICES. If you are using these placeholders, then you must switch from using cloud.<property>. Use vcap.<property> instead.
  3. SMTP Services: Java CfEnv does not currently support detecting and setting properties for SMTP type services


App uses Spring Boot 3 and does have Spring Cloud Connectors as a dependency

Java CfEnv is not compatible with Spring Cloud Connectors (deprecated in 2019) and applications that use both and are bound to one of the above services, will fail to start. Since the buildpack will install Java CfEnv for Boot 3 applications from Java Buildpack version 4.62.0, it will conflict with any manually added Spring Cloud Connectors dependency.


You can identify if the application uses Spring Boot 3 and does have Spring Cloud Connectors as a dependency if you see the following error:

java.lang.IllegalStateException: Exiting the application since the Spring Cloud Connector library has been detected on the classpath.  Please remove this dependency from your project and set the environment variable JBP_CONFIG_SPRING_AUTO_RECONFIGURATION '{enabled: false}' in the Cloud Foundry manifest.


Workaround:

  1. Migrate to Java CfEnv by removing Spring Cloud Connectors as a dependency from your application. This should stop the app crashing and allow Java CfEnv to provide service information to Spring Boot. If you still have issues, check the migration guide for further steps.
  2. If step number one does not work, and you cannot follow the migration steps, you can disable the Buildpack’s Java CfEnv framework with the following environment variable: JBP_CONFIG_JAVA_CF_ENV '{enabled: false}' This is not recommended however, you should migrate as soon as possible.