spring-bootspring-cloudspring-vault

Unable to instantiate VaultConfigDataLoader


I'm trying to configure Spring Cloud Vault in my Spring Boot application (v. 2.4.2). I'm using Spring Cloud v. 2020.0.5 (which, according to the Release train, should be fine).

C:\Tools\jdk1.8.0_92\bin\java.exe -Dspring.profiles.active=DEV,local -javaagent:C:\Apps\IC\idealC-2021.1.2\lib\idea_rt.jar=52879:C:\Apps\IC\idealC-2021.1.2\bin -Dfile.encoding=UTF-8 -classpath C:\Tools\jdk1.8.0_92\jre\lib\charsets.jar;C:\Tools\jdk1.8.0_92\jre\lib\deploy.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\access-bridge-64.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\cldrdata.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\dnsns.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\jaccess.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\jfxrt.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\localedata.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\nashorn.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\sunec.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\sunjce_provider.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\sunmscapi.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\sunpkcs11.jar;C:\Tools\jdk1.8.0_92\jre\lib\ext\zipfs.jar;C:\Tools\jdk1.8.0_92\jre\lib\javaws.jar;C:\Tools\jdk1.8.0_92\jre\lib\jce.jar;C:\Tools\jdk1.8.0_92\jre\lib\jfr.jar;C:\Tools\jdk1.8.0_92\jre\lib\jfxswt.jar;C:\Tools\jdk1.8.0_92\jre\lib\jsse.jar;C:\Tools\jdk1.8.0_92\jre\lib\management-agent.jar;C:\Tools\jdk1.8.0_92\jre\lib\plugin.jar;C:\Tools\jdk1.8.0_92\jre\lib\resources.jar;C:\Tools\jdk1.8.0_92\jre\lib\rt.jar;C:\repositories\org\apache\cxf\cxf-spring-boot-starter-jaxws\3.4.5\cxf-spring-boot-starter-jaxws-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-spring-boot-autoconfigure\3.4.5\cxf-spring-boot-autoconfigure-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-transports-http\3.4.5\cxf-rt-transports-http-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-core\3.4.5\cxf-core-3.4.5.jar;C:\repositories\com\fasterxml\woodstox\woodstox-core\6.2.6\woodstox-core-6.2.6.jar;C:\repositories\org\codehaus\woodstox\stax2-api\4.2.1\stax2-api-4.2.1.jar;C:\repositories\org\apache\ws\xmlschema\xmlschema-core\2.2.5\xmlschema-core-2.2.5.jar;C:\repositories\org\apache\cxf\cxf-rt-frontend-jaxws\3.4.5\cxf-rt-frontend-jaxws-3.4.5.jar;C:\repositories\xml-resolver\xml-resolver\1.2\xml-resolver-1.2.jar;C:\repositories\org\ow2\asm\asm\9.2\asm-9.2.jar;C:\repositories\org\apache\cxf\cxf-rt-bindings-soap\3.4.5\cxf-rt-bindings-soap-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-wsdl\3.4.5\cxf-rt-wsdl-3.4.5.jar;C:\repositories\wsdl4j\wsdl4j\1.6.3\wsdl4j-1.6.3.jar;C:\repositories\org\apache\cxf\cxf-rt-databinding-jaxb\3.4.5\cxf-rt-databinding-jaxb-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-bindings-xml\3.4.5\cxf-rt-bindings-xml-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-frontend-simple\3.4.5\cxf-rt-frontend-simple-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-ws-addr\3.4.5\cxf-rt-ws-addr-3.4.5.jar;C:\repositories\org\apache\cxf\cxf-rt-ws-policy\3.4.5\cxf-rt-ws-policy-3.4.5.jar;C:\repositories\org\apache\neethi\neethi\3.1.1\neethi-3.1.1.jar;C:\repositories\org\apache\cxf\cxf-rt-features-metrics\3.4.5\cxf-rt-features-metrics-3.4.5.jar;C:\repositories\jakarta\validation\jakarta.validation-api\2.0.2\jakarta.validation-api-2.0.2.jar;C:\repositories\org\springframework\boot\spring-boot-starter\2.4.2\spring-boot-starter-2.4.2.jar;C:\repositories\org\springframework\boot\spring-boot-starter-logging\2.4.2\spring-boot-starter-logging-2.4.2.jar;C:\repositories\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\repositories\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\repositories\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;C:\repositories\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;C:\repositories\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\repositories\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\repositories\org\yaml\snakeyaml\1.27\snakeyaml-1.27.jar;C:\repositories\org\apache\commons\commons-lang3\3.0\commons-lang3-3.0.jar;C:\repositories\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar;C:\repositories\javax\xml\stream\stax-api\1.0-2\stax-api-1.0-2.jar;C:\repositories\javax\activation\activation\1.1\activation-1.1.jar;C:\repositories\com\sun\xml\bind\jaxb-impl\2.1.13\jaxb-impl-2.1.13.jar;C:\repositories\org\springframework\security\spring-security-core\5.4.2\spring-security-core-5.4.2.jar;C:\repositories\org\springframework\spring-aop\5.3.3\spring-aop-5.3.3.jar;C:\repositories\org\springframework\spring-expression\5.3.3\spring-expression-5.3.3.jar;C:\repositories\org\springframework\spring-context\5.3.3\spring-context-5.3.3.jar;C:\repositories\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\repositories\org\springframework\spring-web\5.3.3\spring-web-5.3.3.jar;C:\repositories\org\springframework\security\spring-security-config\5.4.2\spring-security-config-5.4.2.jar;C:\repositories\org\springframework\security\spring-security-web\5.4.2\spring-security-web-5.4.2.jar;C:\repositories\org\springframework\boot\spring-boot-starter-web\2.4.2\spring-boot-starter-web-2.4.2.jar;C:\repositories\org\springframework\boot\spring-boot-starter-json\2.4.2\spring-boot-starter-json-2.4.2.jar;C:\repositories\com\fasterxml\jackson\core\jackson-databind\2.11.4\jackson-databind-2.11.4.jar;C:\repositories\com\fasterxml\jackson\core\jackson-annotations\2.11.4\jackson-annotations-2.11.4.jar;C:\repositories\com\fasterxml\jackson\core\jackson-core\2.11.4\jackson-core-2.11.4.jar;C:\repositories\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.4\jackson-datatype-jdk8-2.11.4.jar;C:\repositories\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.4\jackson-datatype-jsr310-2.11.4.jar;C:\repositories\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.4\jackson-module-parameter-names-2.11.4.jar;C:\repositories\org\springframework\boot\spring-boot-starter-tomcat\2.4.2\spring-boot-starter-tomcat-2.4.2.jar;C:\repositories\org\apache\tomcat\embed\tomcat-embed-core\9.0.41\tomcat-embed-core-9.0.41.jar;C:\repositories\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.41\tomcat-embed-websocket-9.0.41.jar;C:\repositories\org\springframework\spring-webmvc\5.3.3\spring-webmvc-5.3.3.jar;C:\repositories\org\springframework\boot\spring-boot-starter-validation\2.4.2\spring-boot-starter-validation-2.4.2.jar;C:\repositories\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;C:\repositories\org\hibernate\validator\hibernate-validator\6.1.7.Final\hibernate-validator-6.1.7.Final.jar;C:\repositories\org\jboss\logging\jboss-logging\3.4.1.Final\jboss-logging-3.4.1.Final.jar;C:\repositories\com\fasterxml\classmate\1.5.1\classmate-1.5.1.jar;C:\repositories\org\springframework\boot\spring-boot-starter-data-jpa\2.4.2\spring-boot-starter-data-jpa-2.4.2.jar;C:\repositories\org\springframework\boot\spring-boot-starter-aop\2.4.2\spring-boot-starter-aop-2.4.2.jar;C:\repositories\org\aspectj\aspectjweaver\1.9.6\aspectjweaver-1.9.6.jar;C:\repositories\org\springframework\boot\spring-boot-starter-jdbc\2.4.2\spring-boot-starter-jdbc-2.4.2.jar;C:\repositories\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;C:\repositories\org\springframework\spring-jdbc\5.3.3\spring-jdbc-5.3.3.jar;C:\repositories\jakarta\transaction\jakarta.transaction-api\1.3.3\jakarta.transaction-api-1.3.3.jar;C:\repositories\jakarta\persistence\jakarta.persistence-api\2.2.3\jakarta.persistence-api-2.2.3.jar;C:\repositories\org\hibernate\hibernate-core\5.4.27.Final\hibernate-core-5.4.27.Final.jar;C:\repositories\org\javassist\javassist\3.27.0-GA\javassist-3.27.0-GA.jar;C:\repositories\net\bytebuddy\byte-buddy\1.10.19\byte-buddy-1.10.19.jar;C:\repositories\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\repositories\org\jboss\jandex\2.1.3.Final\jandex-2.1.3.Final.jar;C:\repositories\org\dom4j\dom4j\2.1.3\dom4j-2.1.3.jar;C:\repositories\org\hibernate\common\hibernate-commons-annotations\5.1.2.Final\hibernate-commons-annotations-5.1.2.Final.jar;C:\repositories\org\glassfish\jaxb\jaxb-runtime\2.3.3\jaxb-runtime-2.3.3.jar;C:\repositories\jakarta\xml\bind\jakarta.xml.bind-api\2.3.3\jakarta.xml.bind-api-2.3.3.jar;C:\repositories\org\glassfish\jaxb\txw2\2.3.3\txw2-2.3.3.jar;C:\repositories\com\sun\istack\istack-commons-runtime\3.0.11\istack-commons-runtime-3.0.11.jar;C:\repositories\com\sun\activation\jakarta.activation\1.2.2\jakarta.activation-1.2.2.jar;C:\repositories\org\springframework\data\spring-data-jpa\2.4.3\spring-data-jpa-2.4.3.jar;C:\repositories\org\springframework\data\spring-data-commons\2.4.3\spring-data-commons-2.4.3.jar;C:\repositories\org\springframework\spring-orm\5.3.3\spring-orm-5.3.3.jar;C:\repositories\org\springframework\spring-tx\5.3.3\spring-tx-5.3.3.jar;C:\repositories\org\springframework\spring-aspects\5.3.3\spring-aspects-5.3.3.jar;C:\repositories\org\springframework\cloud\spring-cloud-starter-vault-config\3.0.5\spring-cloud-starter-vault-config-3.0.5.jar;C:\repositories\org\apache\httpcomponents\httpclient\4.5.13\httpclient-4.5.13.jar;C:\repositories\org\apache\httpcomponents\httpcore\4.4.14\httpcore-4.4.14.jar;C:\repositories\org\springframework\cloud\spring-cloud-starter\3.0.5\spring-cloud-starter-3.0.5.jar;C:\repositories\org\springframework\cloud\spring-cloud-context\3.0.5\spring-cloud-context-3.0.5.jar;C:\repositories\org\springframework\security\spring-security-crypto\5.4.2\spring-security-crypto-5.4.2.jar;C:\repositories\org\springframework\cloud\spring-cloud-commons\3.0.5\spring-cloud-commons-3.0.5.jar;C:\repositories\org\springframework\security\spring-security-rsa\1.0.10.RELEASE\spring-security-rsa-1.0.10.RELEASE.jar;C:\repositories\org\springframework\cloud\spring-cloud-vault-config\3.0.5\spring-cloud-vault-config-3.0.5.jar;C:\repositories\org\springframework\vault\spring-vault-core\2.3.2\spring-vault-core-2.3.2.jar;C:\repositories\com\ibm\mq\mq-jms-spring-boot-starter\2.4.2\mq-jms-spring-boot-starter-2.4.2.jar;C:\repositories\com\ibm\mq\com.ibm.mq.allclient\9.2.1.0\com.ibm.mq.allclient-9.2.1.0.jar;C:\repositories\org\bouncycastle\bcprov-jdk15on\1.66\bcprov-jdk15on-1.66.jar;C:\repositories\org\bouncycastle\bcpkix-jdk15on\1.66\bcpkix-jdk15on-1.66.jar;C:\repositories\javax\jms\javax.jms-api\2.0.1\javax.jms-api-2.0.1.jar;C:\repositories\org\json\json\20080701\json-20080701.jar;C:\repositories\org\springframework\spring-core\5.3.3\spring-core-5.3.3.jar;C:\repositories\org\springframework\spring-jcl\5.3.3\spring-jcl-5.3.3.jar;C:\repositories\org\springframework\spring-beans\5.3.3\spring-beans-5.3.3.jar;C:\repositories\org\springframework\spring-jms\5.3.3\spring-jms-5.3.3.jar;C:\repositories\org\springframework\spring-messaging\5.3.3\spring-messaging-5.3.3.jar;C:\repositories\org\messaginghub\pooled-jms\1.2.1\pooled-jms-1.2.1.jar;C:\repositories\org\apache\geronimo\specs\geronimo-jms_2.0_spec\1.0-alpha-2\geronimo-jms_2.0_spec-1.0-alpha-2.jar;C:\repositories\org\apache\commons\commons-pool2\2.9.0\commons-pool2-2.9.0.jar;C:\repositories\org\springframework\boot\spring-boot\2.4.2\spring-boot-2.4.2.jar;C:\repositories\org\springframework\boot\spring-boot-autoconfigure\2.4.2\spring-boot-autoconfigure-2.4.2.jar;C:\repositories\net\sf\dozer\dozer\5.5.1\dozer-5.5.1.jar;C:\repositories\commons-beanutils\commons-beanutils\1.8.0\commons-beanutils-1.8.0.jar;C:\repositories\org\slf4j\jcl-over-slf4j\1.7.30\jcl-over-slf4j-1.7.30.jar;C:\repositories\commons-io\commons-io\1.3.2\commons-io-1.3.2.jar;C:\repositories\commons-configuration\commons-configuration\1.10\commons-configuration-1.10.jar;C:\repositories\commons-lang\commons-lang\2.4\commons-lang-2.4.jar;C:\repositories\commons-logging\commons-logging\1.1.1\commons-logging-1.1.1.jar;C:\repositories\commons-codec\commons-codec\1.10\commons-codec-1.10.jar;C:\repositories\stax\stax\1.2.0\stax-1.2.0.jar;C:\repositories\com\ibm\mq\mqjms\7.0.1.7\mqjms-7.0.1.7.jar;C:\repositories\com\ibm\mq\dhbcore\7.0.1.7\dhbcore-7.0.1.7.jar;C:\repositories\com\ibm\mq\jmqi\7.0.1.7\jmqi-7.0.1.7.jar;C:\repositories\com\google\guava\guava\13.0-rc2\guava-13.0-rc2.jar;C:\repositories\com\oracle\jdbc\ojdbc8\12.2.0.1.0\ojdbc8-12.2.0.1.0.jar;C:\repositories\com\oracle\jdbc\ucp\12.2.0.1\ucp-12.2.0.1.jar;C:\repositories\net\sf\ehcache\ehcache-core\2.3.1\ehcache-core-2.3.1.jar com.example.ExampleServApplication
17:00:24.235 [main] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.IllegalArgumentException: Unable to instantiate org.springframework.boot.context.config.ConfigDataLoader [org.springframework.cloud.vault.config.VaultConfigDataLoader]
                at org.springframework.boot.util.Instantiator.instantiate(Instantiator.java:103)
                at org.springframework.boot.util.Instantiator.instantiate(Instantiator.java:90)
                at org.springframework.boot.context.config.ConfigDataLoaders.<init>(ConfigDataLoaders.java:75)
                at org.springframework.boot.context.config.ConfigDataLoaders.<init>(ConfigDataLoaders.java:56)
                at org.springframework.boot.context.config.ConfigDataEnvironment.<init>(ConfigDataEnvironment.java:155)
                at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.getConfigDataEnvironment(ConfigDataEnvironmentPostProcessor.java:108)
                at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:97)
                at org.springframework.boot.context.config.ConfigDataEnvironmentPostProcessor.postProcessEnvironment(ConfigDataEnvironmentPostProcessor.java:89)
                at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEnvironmentPreparedEvent(EnvironmentPostProcessorApplicationListener.java:100)
                at org.springframework.boot.env.EnvironmentPostProcessorApplicationListener.onApplicationEvent(EnvironmentPostProcessorApplicationListener.java:86)
                at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:176)
                at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:169)
                at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:143)
                at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:131)
                at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:82)
                at org.springframework.boot.SpringApplicationRunListeners.lambda$environmentPrepared$2(SpringApplicationRunListeners.java:63)
                at java.util.ArrayList.forEach(ArrayList.java:1249)
                at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:117)
                at org.springframework.boot.SpringApplicationRunListeners.doWithListeners(SpringApplicationRunListeners.java:111)
                at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:62)
                at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:362)
                at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
                at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:144)
                at com.example.ExampleServApplication.main(ExampleServApplication.java:29)
Caused by: java.lang.IllegalAccessException: Unable to find suitable constructor
                at org.springframework.boot.util.Instantiator.instantiate(Instantiator.java:118)
                at org.springframework.boot.util.Instantiator.instantiate(Instantiator.java:100)
                ... 23 common frames omitted

Any idea what might be wrong ? Am I missing some dependencies ?


Solution

  • I found the problem. It seems that these particular set of versions is incompatible (even though the release train says otherwise):

    The problem is that the class ConfigDataLoaders supports DeferredLogFactory injection only in spring-boot 2.4.3:

    https://github.com/spring-projects/spring-boot/commit/1def245a2cb7f5aa520531059956c3c3794625d7

    On the other hand, starting with Spring Cloud 3.0.2, VaultConfigDataLoader has a new constructor accepting a DeferredLogFactory:

    https://github.com/spring-cloud/spring-cloud-vault/commit/a9fd88c3b768a1f6e485851423dd8f62afae71ba

    So, either use Spring Boot 2.4.2 and Spring Cloud 3.0.1 (or lower) or use Spring Boot 2.4.3 and Spring Cloud 3.0.2+.

    I hope this investigation will save somebody some time, as it took me about half a day..