Search code examples
spring-bootspring-cloudspring-cloud-sleuth

getting 'Context Initialization' error when adding spring-cloud-sleuth to classpath


Portion of the build file that references spring-cloud-sleuth is provided below.

dependencyManagement {
  imports {
        //where springCloudVersion = "Dalston.SR5" & springBootVersion = '1.5.9.RELEASE'

    mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
  }
} 
//in dependencies, added the following line
compile 'org.springframework.cloud:spring-cloud-starter-sleuth'

after adding this dependency, the application fails to start with the following exception (added based on comments)

support.AbstractApplicationContext (AbstractApplicationContext.java:551) - 
Exception encountered during context initialization - cancelling refresh attempt: 
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'misds': 
Could not bind properties to HikariDataSource (prefix=mis.datasource, ignoreInvalidFields=false, ignoreUnknownFields=true, ignoreNestedProperties=false); nested exception is org.springframework.validation.BindException: org.springframework.boot.bind.RelaxedDataBinder$RelaxedBeanPropertyBindingResult: 4 errors
Field error in object 'mis.datasource' on field 'driverClassName': rejected value [oracle.jdbc.OracleDriver]; 
codes [methodInvocation.mis.datasource.driverClassName,methodInvocation.driverClassName,methodInvocation.java.lang.String,methodInvocation]; 
arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [mis.datasource.driverClassName,driverClassName]; 
arguments []; default message [driverClassName]]; default message [Property 'driverClassName' threw exception; 
nested exception is java.lang.IllegalStateException: The configuration of the pool is sealed once started.  
Use HikariConfigMXBean for runtime changes.]

I am using slf4j over log4j for logging framework and the application runs fine when I remove the sleuth dependency.

I noticed that the following 'additional' propertysources are present when spring-cloud dependency is included.

env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'springCloudClientHostInfo' with lowest search precedence
env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'defaultProperties' with lowest search precedence
env.MutablePropertySources (MutablePropertySources.java:106) - Adding PropertySource 'Management Server' with lowest search precedence

Solution

  • Always check if the latest release train doesn't solve your problems. Honestly, I don't really know which issue is related to this problem :/ Edgware release train is compatible with Boot < 2.0