Spring-cloud-config: Native profile not compatible with server bootstrapping

Created on 12 Jun 2018  路  10Comments  路  Source: spring-cloud/spring-cloud-config

I upgraded our spring cloud config server from Finchley.RC1 to RC2 and our integration test broke. The integration test is using a native repository (spring.profiles.active=native). Our main bootstrap file has spring.cloud.config.server.bootstrap=true

This previously worked fine in RC1. The error I'm getting is in the creation of the DefaultRepositoryConfiguration which should not be created using the native profile from my understanding.

Caused by: java.lang.NullPointerException
    at org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.addHttpClient(HttpClientConfigurableHttpConnectionFactory.java:60)
    at org.springframework.cloud.config.server.environment.HttpClientConfigurableHttpConnectionFactory.addConfiguration(HttpClientConfigurableHttpConnectionFactory.java:43)
    at org.springframework.cloud.config.server.environment.MultipleJGitEnvironmentRepositoryFactory.build(MultipleJGitEnvironmentRepositoryFactory.java:59)
    at org.springframework.cloud.config.server.config.DefaultRepositoryConfiguration.defaultEnvironmentRepository(EnvironmentRepositoryConfiguration.java:209)
    at org.springframework.cloud.config.server.config.DefaultRepositoryConfiguration$$EnhancerBySpringCGLIB$$b63f2d53.CGLIB$defaultEnvironmentRepository$0(<generated>)
    at org.springframework.cloud.config.server.config.DefaultRepositoryConfiguration$$EnhancerBySpringCGLIB$$b63f2d53$$FastClassBySpringCGLIB$$b07c0778.invoke(<generated>)
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361)
    at org.springframework.cloud.config.server.config.DefaultRepositoryConfiguration$$EnhancerBySpringCGLIB$$b63f2d53.defaultEnvironmentRepository(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154)
    ... 105 more`

When running with --debug flag i get the appropriate configurations based on matching.

`NativeRepositoryConfiguration matched:
      - @ConditionalOnMissingBean (types: org.springframework.cloud.config.server.environment.EnvironmentRepository; SearchStrategy: all) did not find any beans (OnBeanCondition)`

DefaultRepositoryConfiguration:
      Did not match:
         - @ConditionalOnMissingBean (types: org.springframework.cloud.config.server.environment.EnvironmentRepository; SearchStrategy: current) found beans of type 'org.springframework.cloud.config.server.environment.EnvironmentRepository' nativeEnvironmentRepository (OnBeanCondition)

My fix is to turn off bootstrapping for the integration test, but I'm sure there are people that would like to use this feature. Thank you so much for this awesome project!

documentation enhancement

Most helpful comment

We talked about and will do two things, note the use of the composite style config if you are using bootstrap and implement a failure analyzer to tell you if your project is in a bad state.

All 10 comments

This is duplicate and has been fixed.

@spencergibb

I'm sorry, but I don't think this is a duplicate, nor has it been fixed. I have just run with Finchley.RELEASE. The configuration is assuming a git repo when bootstrapping is turned on.

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'defaultEnvironmentRepository' defined in class path resource [org/springframework/cloud/config/server/config/DefaultRepositoryConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: You need to configure a uri for the git repository

Looks like this was caused by #1014

Using the composite configuration works:

spring:
  application:
    name: configserver
  profiles:
    active: composite
  cloud:
    config:
      server:
        composite:
          - type: native
            search-locations: ${HOME}/Desktop/config
        bootstrap: true

@ryanjbaxter @pivotal-dylan-roberts @fifthposition I know there was a discussion on only documenting the composite way of doing things, here is a technical reason to do so, spring.cloud.config.server.bootstrap=true.

Thank you, @spencergibb. I will give that a try locally for our integration test.

This work-around allows our integration tests to work properly. Thank you.

We talked about and will do two things, note the use of the composite style config if you are using bootstrap and implement a failure analyzer to tell you if your project is in a bad state.

Thank you! We will keep our usage of composite then.

Fixed via 8b122cc and 4ae00c9

Was this page helpful?
0 / 5 - 0 ratings