Spring Cloud Config Server failed to start with the message below(omitted lots of stacktraces).
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'environmentEncryptor' defined in class path resource [org/springframework/cloud/config/server/config/EncryptionAutoConfiguration$EncryptorConfiguration.class]: Post-processing of merged bean definition failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.cloud.config.server.encryption.CipherEnvironmentEncryptor] from ClassLoader [sun.misc.Launcher$AppClassLoader@73d16e93]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553) ~[spring-beans-5.1.4.RELEASE.jar:5.1.4.RELEASE]
...
...
Caused by: java.lang.NoClassDefFoundError: org/springframework/cloud/config/environment/Environment
My build configs are like below(just partial).
// build.gradle
buildscript {
ext {
springBootVersion = '2.1.2.RELEASE'
springCloudVersion = 'Greenwich.RELEASE'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
dependencies {
implementation "org.springframework.cloud:spring-cloud-config-server"
}
and application.yml for this application.
#application.yml
spring:
application:
name: config-server
profiles:
active: native
cloud:
config:
server:
native:
search-locations: classpath:/configs
Is there anything I misunderstood configuration?
Comment From: spencergibb
Can you show the depenency tree output from gradle.
Comment From: themuser
Below is the dependency tree. This project is in standalone environment depends on standalone nexus.
Seems like dependency for spring-cloud-config-client
is missing comparing to working-correctly-version. Still does not work after manually adding spring-cloud-config-client
dependency though.
compileClasspath - Compile classpath for source set 'main'.
+--- org.springframework.boot:spring-boot-starter-actuator -> 2.1.2.RELEASE
| +--- org.springframework.boot:spring-boot-starter:2.1.2.RELEASE
| | +--- org.springframework.boot:spring-boot:2.1.2.RELEASE
| | | +--- org.springframework:spring-core:5.1.4.RELEASE
| | | | \--- org.springframework:spring-jcl:5.1.4.RELEASE
| | | \--- org.springframework:spring-context:5.1.4.RELEASE
| | | +--- org.springframework:spring-aop:5.1.4.RELEASE
| | | | +--- org.springframework:spring-beans:5.1.4.RELEASE
| | | | | \--- org.springframework:spring-core:5.1.4.RELEASE (*)
| | | | \--- org.springframework:spring-core:5.1.4.RELEASE (*)
| | | +--- org.springframework:spring-beans:5.1.4.RELEASE (*)
| | | +--- org.springframework:spring-core:5.1.4.RELEASE (*)
| | | \--- org.springframework:spring-expression:5.1.4.RELEASE
| | | \--- org.springframework:spring-core:5.1.4.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.1.2.RELEASE
| | | \--- org.springframework.boot:spring-boot:2.1.2.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-starter-logging:2.1.2.RELEASE
| | | +--- ch.qos.logback:logback-classic:1.2.3
| | | | +--- ch.qos.logback:logback-core:1.2.3
| | | | \--- org.slf4j:slf4j-api:1.7.25
| | | +--- org.apache.logging.log4j:log4j-to-slf4j:2.11.1
| | | | +--- org.slf4j:slf4j-api:1.7.25
| | | | \--- org.apache.logging.log4j:log4j-api:2.11.1
| | | \--- org.slf4j:jul-to-slf4j:1.7.25
| | | \--- org.slf4j:slf4j-api:1.7.25
| | +--- javax.annotation:javax.annotation-api:1.3.2
| | \--- org.springframework:spring-core:5.1.4.RELEASE (*)
| +--- org.springframework.boot:spring-boot-actuator-autoconfigure:2.1.2.RELEASE
| | +--- org.springframework.boot:spring-boot-actuator:2.1.2.RELEASE
| | | \--- org.springframework.boot:spring-boot:2.1.2.RELEASE (*)
| | +--- org.springframework.boot:spring-boot-autoconfigure:2.1.2.RELEASE (*)
| | +--- com.fasterxml.jackson.core:jackson-databind:2.9.8
| | | +--- com.fasterxml.jackson.core:jackson-annotations:2.9.0
| | | \--- com.fasterxml.jackson.core:jackson-core:2.9.8
| | +--- org.springframework:spring-core:5.1.4.RELEASE (*)
| | \--- org.springframework:spring-context:5.1.4.RELEASE (*)
| \--- io.micrometer:micrometer-core:1.1.2
| +--- org.hdrhistogram:HdrHistogram:2.1.9
| \--- org.latencyutils:LatencyUtils:2.0.3
\--- org.springframework.cloud:spring-cloud-config-server -> 2.1.0.RELEASE
Comment From: themuser
On Standalone Environment
\--- org.springframework.cloud:spring-cloud-config-server -> 2.1.0.RELEASE
// end of tree
In this case, remote mvn repository is Nexus On-Premise.
On Internet Environment
\--- org.springframework.cloud:spring-cloud-config-server -> 2.1.0.RELEASE
+--- org.springframework.cloud:spring-cloud-config-client:2.1.0.RELEASE
| +--- org.springframework.boot:spring-boot-autoconfigure:2.1.2.RELEASE (*)
| +--- org.springframework.cloud:spring-cloud-commons:2.1.0.RELEASE
...
...
In this case, remote mvn repository is mavenCentral()
Comment From: spencergibb
Not much we can do about an internal Nexus problem
Comment From: themuser
Resolved
Just renewed internal Nexus dependency for Spring Cloud Greenwich.SR1(previously Greenwich.RELASE) which seems not to be a fundamental solution.
Thank you for the support :)
Comment From: sanseervi
Hi I am getting a similar issue with Spring cloud version Huxton.SR3 and Spring Boot version 2.2.6. Please suggest
Comment From: themuser
@sanseervi If your are doing it in on-prem, why don't you make your project built in the internet environment and compare the dependency trees?
Comment From: SubhankarMukherjee
I am also facing the same issue. My Spring boot version is 2.6.0 Snapshot and spring cloud version is 021.0.0-SNAPSHOT. Kindly suggest