Skip to content

[BUG] Azure App Config not Working in Spring boot 4.x / spring framework 7.x beta #47623

@kazi-uddin

Description

@kazi-uddin

Describe the bug
We are currently testing the beta version of v7 and running into issues when starting the application.
We are using azure app config. But it's unable to create the AppConfigurationRefresh bean due to missing dependencies. It says Factory method 'appConfigurationRefresh' threw exception with message: com.azure.spring.cloud.appconfiguration.config.implementation.AppConfigurationReplicaClientFactory has not been registered

Exception or Stack Trace

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'appConfigurationRefresh' defined in class path resource [com/azure/spring/cloud/appconfiguration/config/AppConfigurationWatchAutoConfiguration.class]: Failed to instantiate [com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh]: Factory method 'appConfigurationRefresh' threw exception with message: com.azure.spring.cloud.appconfiguration.config.implementation.AppConfigurationReplicaClientFactory has not been registered
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:657) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:645) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1362) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1194) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:565) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:525) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:333) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:371) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:331) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:196) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.instantiateSingleton(DefaultListableBeanFactory.java:1218) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingleton(DefaultListableBeanFactory.java:1184) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:1121) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:983) ~[spring-context-7.0.1.jar:7.0.1]
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:620) ~[spring-context-7.0.1.jar:7.0.1]
	at org.springframework.boot.web.server.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-web-server-4.0.0.jar:4.0.0]
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:765) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:454) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:321) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1374) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1363) ~[spring-boot-4.0.0.jar:4.0.0]
	at com.example.FeatureManagerWebApplication.main(FeatureManagerWebApplication.java:11) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.azure.spring.cloud.appconfiguration.config.AppConfigurationRefresh]: Factory method 'appConfigurationRefresh' threw exception with message: com.azure.spring.cloud.appconfiguration.config.implementation.AppConfigurationReplicaClientFactory has not been registered
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:183) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiateWithFactoryMethod(SimpleInstantiationStrategy.java:72) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:152) ~[spring-beans-7.0.1.jar:7.0.1]
	at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-7.0.1.jar:7.0.1]
	... 21 common frames omitted
Caused by: java.lang.IllegalStateException: com.azure.spring.cloud.appconfiguration.config.implementation.AppConfigurationReplicaClientFactory has not been registered
	at org.springframework.boot.bootstrap.DefaultBootstrapContext.lambda$get$0(DefaultBootstrapContext.java:90) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.bootstrap.DefaultBootstrapContext.getOrElseThrow(DefaultBootstrapContext.java:113) ~[spring-boot-4.0.0.jar:4.0.0]
	at org.springframework.boot.bootstrap.DefaultBootstrapContext.get(DefaultBootstrapContext.java:90) ~[spring-boot-4.0.0.jar:4.0.0]
	at com.azure.spring.cloud.appconfiguration.config.AppConfigurationWatchAutoConfiguration.appConfigurationRefresh(AppConfigurationWatchAutoConfiguration.java:41) ~[spring-cloud-azure-appconfiguration-config-7.0.0-beta.1.jar:7.0.0-beta.1]
	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103) ~[na:na]
	at java.base/java.lang.reflect.Method.invoke(Method.java:580) ~[na:na]
	at org.springframework.beans.factory.support.SimpleInstantiationStrategy.lambda$instantiate$0(SimpleInstantiationStrategy.java:155) ~[spring-beans-7.0.1.jar:7.0.1]

To Reproduce
Steps to reproduce the behavior:

Used this example from here:
https://github.com/Azure-Samples/azure-spring-boot-samples/tree/spring-boot-4.x/appconfiguration/spring-cloud-azure-feature-management-web/spring-cloud-azure-feature-management-web-sample

Added app configuration web dependency in pom

<dependency>
    <groupId>com.azure.spring</groupId>
    <artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
</dependency>

Added in application.yml

spring:
  thymeleaf:
    cache: false
  cloud:
    azure:
      appconfiguration:
        enabled: true
        stores:
          - connection-string: Endpoint=https://**************************
            feature-flags:
              enabled: true
        credential:
          managed-identity-enabled: false

Code Snippet
See above

Expected behavior
The application should connect to azure app config server and fetch app configuration including feature flags.

Screenshots

Image

Setup (please complete the following information):

  • OS: Ubintu 24.04
  • IDE: IntelliJ
  • Library/Libraries: spring-cloud-azure-appconfiguration-config-web
  • Java version: 17, 21
  • App Server/Environment: Tomcat
  • Frameworks: Spring Boot v4

If you suspect a dependency version mismatch (e.g. you see NoClassDefFoundError, NoSuchMethodError or similar), please check out Troubleshoot dependency version conflict article first. If it doesn't provide solution for the problem, please provide:

  • verbose dependency tree (mvn dependency:tree -Dverbose)
  • exception message, full stack trace, and any available logs

Additional context
See above

Information Checklist
Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report

  • Bug Description Added
  • Repro Steps Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.azure-springAll azure-spring related issuesbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions