Closed srikanth550 closed 4 years ago
you need to use composite profile and configuration with bootstrap just like the action says
Changed my bootstrap.yml to below composite config
spring:
profiles:
active: composite
cloud:
config:
server:
profile: test
label: sample-config
composite:
- type: awss3
search-locations: s3://srikanth-sg-demo-config-server/sample-config
bootstrap: true
And got these exceptions and here is the stack trace
2020-06-02 15:30:46.334 INFO 16192 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.0.RELEASE)
2020-06-02 15:30:46.849 INFO 16192 --- [ main] c.s.java.ConfigserverdemoApplication : The following profiles are active: composite
2020-06-02 15:30:47.869 ERROR 16192 --- [ main] o.s.boot.SpringApplication : Application run failed
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.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.context.annotation.ConditionEvaluator.shouldSkip(ConditionEvaluator.java:108) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForBeanMethod(ConfigurationClassBeanDefinitionReader.java:184) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitionsForConfigurationClass(ConfigurationClassBeanDefinitionReader.java:144) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader.loadBeanDefinitions(ConfigurationClassBeanDefinitionReader.java:120) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:331) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:236) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:280) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:706) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:532) ~[spring-context-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.0.RELEASE.jar:2.3.0.RELEASE]
at com.srikanth.java.ConfigserverdemoApplication.main(ConfigserverdemoApplication.java:12) [classes/:na]
Caused by: java.lang.NullPointerException: null
at java.util.concurrent.ConcurrentHashMap.get(Unknown Source) ~[na:1.8.0_151]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanDefinition(DefaultListableBeanFactory.java:809) ~[spring-beans-5.2.6.RELEASE.jar:5.2.6.RELEASE]
at org.springframework.cloud.config.server.composite.CompositeUtils.getEnvironmentRepositoryFactoryTypeParams(CompositeUtils.java:82) ~[spring-cloud-config-server-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.cloud.config.server.composite.OnSearchPathLocatorPresent.getMatchOutcome(OnSearchPathLocatorPresent.java:49) ~[spring-cloud-config-server-2.2.0.RELEASE.jar:2.2.0.RELEASE]
at org.springframework.boot.autoconfigure.condition.SpringBootCondition.matches(SpringBootCondition.java:47) ~[spring-boot-autoconfigure-2.3.0.RELEASE.jar:2.3.0.RELEASE]
... 18 common frames omitted
what are you dependencies?
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Can you retry with Hoxton.SR5 (the latest)?
Getting same exceptions as above after changing the version to Hoxton.SR5.
Is the syntax for s3 search-locations field correct?
Should I use uri instead of search-locations?
Hello Did this issue resolve ? @srikanth
spring:
profiles:
active: composite
cloud:
config:
server:
profile: test
label: sample-config
composite:
- type: aws
bucket: srikanth-sg-demo-config-server
region: us-east-1
bootstrap: true
After changing the type to AWS and bucket and region this issue is gone. But it is having issues with connecting to s3 using proxy.
I have posted other question regarding that. Waiting for reply.
Hi @spencergibb ,
We are still facing the same issue, Is there a sample project like the one we have for git? Also can we use embedded server for AWS?
@unnisathya92 what issue? Did you move to use composite for bootstrap?
@spencergibb This is the bootstrap config I have
spring:
profiles:
active: awss3
cloud:
config:
server:
awss3:
region: us-east-1
bucket: antm-amp-test-service-configs
Following is the snippet of my pom.xml
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.1.RELEASE</version>
<relativePath />
</parent>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR5</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>2.3.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
<version>2.2.3.RELEASE</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-s3</artifactId>
<version>1.11.796</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
When I run the app in my local, I get AWS connection exceptions, saying unable to connect to the host, even though I have access. But when I run the same app from an EC2 instance with CLI set up, I get the following error.
2020-06-15 14:35:43.250 INFO 20968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-06-15 14:35:43.722 WARN 20968 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'healthIndicatorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/LegacyHealthEndpointCompatibilityConfiguration.class]: Unsatisfied dependency expressed through method 'healthIndicatorRegistry' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'healthContributorRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/health/HealthEndpointConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.boot.actuate.health.HealthContributorRegistry]: Factory method 'healthContributorRegistry' threw exception; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'configServerHealthIndicator' defined in class path resource [org/springframework/cloud/config/server/config/EnvironmentRepositoryConfiguration.class]: Unsatisfied dependency expressed through method 'configServerHealthIndicator' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cloud.config.server.config.CompositeConfiguration': Unsatisfied dependency expressed through method 'setEnvironmentRepos' parameter 0; nested exception is 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.
2020-06-15 14:35:43.724 INFO 20968 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-06-15 14:35:43.730 INFO 20968 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-06-15 14:35:43.749 INFO 20968 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-06-15 14:35:43.754 ERROR 20968 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Am I doing something wrong? Not sure why is it looking for DefaultRepositoryConfiguration even though my maven dependency has AWSS3RepositoryConfiguration
Your configuration needs to use the composite profile as mentioned and shown here https://github.com/spring-cloud/spring-cloud-config/issues/1635#issuecomment-643434172
Thanks @spencergibb , so if my property file is application-uat.properties sitting in the bucket, is the following config correct
spring:
profiles:
active: composite
cloud:
config:
server:
profile: uat
composite:
- type: aws
bucket: <bucket>
region: us-east-1
bootstrap: true
There's no such property spring.cloud.config.server.profile
. uat
should come from the config client spring.cloud.config.profile
.
Thanks @spencergibb , but is there a way where I can embed this in one server instead of server client configuration?
We've moved beyond the scope of this issue. The closest thing I can think of is spring.cloud.config.server.default-profile
, but I think that only works if the client doesn't send one, and config client always does.
Ok, but I dont have a seperate client app, I am planning to have a single app that reads the properties from s3 bucket. would the bootstrap.yml file be still the same?
spring.cloud.config.profile
@spencergibb Thanks worked like a charm.
this is the bootstrap I used
spring:
profiles:
active: composite
cloud:
config:
profile: uat
server:
composite:
- type: aws
bucket: <bucket>
region: us-east-1
bootstrap: true
management:
endpoints:
web:
exposure:
include: "*"
and I don't have enable //@EnableConfigServer annotation for the main class.
I was facing the same issue when I am using awss3 profile(I am not trying to get properties from multiple backends). For me, the issue was I had an environment variable PROFILE defined with some other value while the value in bootstrap.yml is hardcoded to awss3.
Here is my bootstrap.yml
spring:
profiles:
active: awss3
application:
name: app
cloud:
config:
profile: development
server:
accept-empty: false
bootstrap: true
awss3:
region: ap-south-1
bucket: bucket1
label: development
I removed the environment and its working fine.
Any resolution for the same? I am also facing this issue. I am using native profile. and provided file uri. spring.profiles.active=native spring.cloud.config.server.native.search-locations=file:///C:/Users/username/configrepo/
Any resolution for the same? I am also facing this issue. I am using native profile. and provided file uri. spring.profiles.active=native spring.cloud.config.server.native.search-locations=file:///C:/Users/username/configrepo/
I tried with yaml file and worked:
server:
port: 8081
spring:
profiles:
active: composite
cloud:
config:
server:
composite:
- type: native
search-locations: file:///C:/Users/username/configrepo/
The following configuration worked for me, if an S3 connection could not be established, I am reading the configs from local
spring.application.name={APP_NAME}
spring.profiles.active=composite
spring.cloud.config.profile=${ACTIVE_PROFILES}
spring.cloud.config.server.composite[0].type=aws
spring.cloud.config.server.composite[0].bucket=${S3_CONFIG_BUCKET}
spring.cloud.config.label=${ACTIVE_PROFILES}
spring.cloud.config.server.composite[0].region=${S3_CONFIG_REGION}
spring.cloud.config.server.composite[1].type=native
spring.cloud.config.server.composite[1].search-locations=${localDirectory}/amplified-service-configs/TEST/${ACTIVE_PROFILES}
spring.cloud.config.server.bootstrap=true
Any resolution for the same? I am also facing this issue. I am using native profile. and provided file uri. spring.profiles.active=native spring.cloud.config.server.native.search-locations=file:///C:/Users/username/configrepo/
It will works if rename file bootstrap.yml -> application.yml.
Hi @spencergibb & @hoangIt705, I tried Spring Cloud Config native with this config (bootstrap.yml):
server:
port: 8888
# Spring Cloud with Native
spring:
application:
name: configuration-server
profiles:
active: composite
cloud:
config:
server:
composite:
- type: native
search-locations: file:configs
bootstrap: true
#Disable security of the Management endpoint
management:
security:
enabled: false
eureka:
instance:
instance-id: ${spring.application.name}:${random.uuid}
logging:
level:
org.springframework.web: INFO
But it show error:
***************************
APPLICATION FAILED TO START
***************************
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you are using a native profile and have spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
Process finished with exit code 1
Any suggestion?
Thanks
Updated.
It works by renaming bootstrap.yml
file into application.yml
file again like in this link --> https://stackoverflow.com/questions/65829117/spring-cloud-configuration-server-not-working-with-local-properties-file-getti
@spencergibb i am facing same issue with updated version. Can you please help me on this? Please see below my sample git repo.
https://github.com/jaganm2018/spring-cloud-function-aws
Already I raise issue : 1903 .
please I’m struggling past 7 days.
application.yml
not bootstrap.yml
.This is the right way. Please note !!!
This refrence help me fix my problem: https://cloud.spring.io/spring-cloud-config/multi/multi__spring_cloud_config_server.html.
so hard
The issue arose when I upgraded some of my spring dependencies. I managed to fix this issue by adding the spring bootstrap dependency. This allows the application to use the older legacy bootstrap configuration. More info can be found in the first answer here - https://stackoverflow.com/questions/64994034/bootstrap-yml-configuration-not-processed-anymore-with-spring-cloud-2020-0
`
<artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>`
``> bootstrap: true
`Working configuration!!
logging:
level:
com.aric.samples: TRACE
server:
port: 8082
spring:
cloud:
config:
enabled: false #does not mater
server:
jdbc:
enabled: true
sql: select KK, VV from PROPERTIES where APPLICATION=? and PP=? and LL=?
order: 1
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: mysql@1234
url: jdbc:mysql://localhost:3306/kuebiko_db
#jndi-name: jdbc/config
profiles:
active:
- jdbc
jpa:
#database-platform: org.hibernate.dialect.MySQL5Dialect
show-sql: true
hibernate:
ddl-auto: update
package com.mmk.Insurance.configserver;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication @EnableConfigServer public class InsuranceConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(InsuranceConfigServerApplication.class, args);
}
}
server.port=8888 spring.cloud.config.server.git.uri= https://github.com/midde905/Insurance-Config-Server management.endpoints.web.exposure.include=*
Description:
Invalid config server configuration.
Action:
If you are using the git profile, you need to set a Git URI in your configuration. If you have set spring.cloud.config.server.bootstrap=true, you need to use a composite configuration.
plz help to reslove
Also check if you have an Environment Variable set, that overrides the profile. It will also lead to this error! I had "SPRING_PROFILES_ACTIVE" set and it leads to the config being overriden.
I am trying to use S3 as backend for config server. Below is my bootstarp.yml looks like
Here is the stack trace when I run my spring boot application