'Spring Cloud Config (Embedded): Error processing condition on ompositeRepositoryConfiguration.searchPathCompositeEnvironmentRepository

We are using Spring Cloud Config Server to provide the environment for our Project. However in order to deploy it I have to embed it into the main Spring application. I followed the documentation on how to run the Cloud Config as an embedded server, which means I added the @EnableConfigServer annotation in the main java file, as well as setting spring.cloud.config.server.bootstrap to true.

According to the documentation i created the required bootstrap.yml which looks something like this.

---
spring:
  application:
    name: application

  cloud:
    config:
      label: main
      fail-fast: true
      server:
        composite:
        -
          type: git
          uri: # HTTPS link to Repo
          clone-on-start: true
          default-label: main
        git:
          clone-on-start: true
          default-label: main
        bootstrap: true

However when I try to start the Server it always crashes with the following error: java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration.searchPathCompositeEnvironmentRepository. When I remove the @EnableConfigServer annotation this error does not appear, but the Server crashes anyway because it obviously does not load any configuration anymore.

I read that this problem may have something to do with the Spring Boot and Spring Cloud version in use, but I have attempted it with multiple versions. Currently im on Spring Boot 2.6.3 and Spring Cloud 2021.0.1 which implicitly gives me a spring-cloud-config-server of version 3.1.1

Is there any way to get the embedded Config server working?

Update:

Full Trace:

java.lang.IllegalStateException: Error processing condition on org.springframework.cloud.config.server.config.CompositeRepositoryConfiguration.searchPathCompositeEnvironmentRepository
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:60) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:193) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:153) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:129) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:343) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:247) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:311) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:112) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:746) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:564) ~[spring-context-5.3.15.jar:5.3.15]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:732) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:414) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:302) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1303) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1292) ~[spring-boot-2.6.3.jar:2.6.3]
    at ServerApplication.main(ServerApplication.java:27) ~[classes/:na]
Caused by: java.util.NoSuchElementException: No value bound
    at org.springframework.boot.context.properties.bind.BindResult.get(BindResult.java:55) ~[spring-boot-2.6.3.jar:2.6.3]
    at org.springframework.cloud.config.server.composite.CompositeUtils.getCompositeTypeList(CompositeUtils.java:51) ~[spring-cloud-config-server-3.1.1.jar:3.1.1]
    at org.springframework.cloud.config.server.composite.OnSearchPathLocatorPresent.getMatchOutcome(OnSearchPathLocatorPresent.java:40) ~[spring-cloud-config-server-3.1.1.jar:3.1.1]
    at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.6.3.jar:2.6.3]
    ... 17 common frames omitted


Process finished with exit code 1

application.yml

---
spring:
  cloud:
    config:
      server:
        bootstrap: true

required usernames and passwords are provided via environment variables

ServerApplication.java (main file)


@SpringBootApplication
@EnableConfigServer
@EnableScheduling
@EnableSchedulerLock(defaultLockAtMostFor = "PT5M", interceptMode = EnableSchedulerLock.InterceptMode.PROXY_SCHEDULER, mode = AdviceMode.PROXY)
@EnableAsync
@EnableCaching
@EnableTransactionManagement
public class ServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ServerApplication.class, args);
    }

    @Bean
    public LockProvider lockProvider(DataSource dataSource) {
        return new JdbcTemplateLockProvider(dataSource);
    }

}

Update 2

I made some progress in fixing the error. It came from the active profiles i set (as an env variable). I used "dev" and "composite" even though only the composite profile has been defined in bootstrap.yml

However the application is still crashing on startup because the cloud config server does work

Update 3

I fixed the problems by adding the following dependency

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source