After updating Spring from 5.0.8.RELEASE to 5.1.0.RELEASE and Spring Boot from 2.0.4.RELEASE to 2.1.0.M4, tests annotated with @SpringBootTest
have been failing with a binding error for logging.level
. Error is:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
In most tests, logging.level
is not defined at all, but this error appears. In others, there is an application.yml
file on the classpath (/src/main/resources/
) which has the following defined:
logging:
level:
com.foo.bar: DEBUG
and it still fails. logging.group
is not defined anywhere. These were running fine with Spring 5.0.8 and Spring Boot 2.0.4, but fail when updating to 5.1.0 and 2.1.0.M4.
Full stack trace is:
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:249) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:225) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:209) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:165) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:328) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:309) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:257) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:219) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:192) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:371) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:139) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:197) [spring-cloud-context-2.1.0.M1.jar:2.1.0.M1]
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:104) [spring-cloud-context-2.1.0.M1.jar:2.1.0.M1]
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.onApplicationEvent(BootstrapApplicationListener.java:70) [spring-cloud-context-2.1.0.M1.jar:2.1.0.M1]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) [spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) [spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) [spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) [spring-context-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:75) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:371) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:330) [spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.test.context.SpringBootContextLoader.loadContext(SpringBootContextLoader.java:139) [spring-boot-test-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContextInternal(DefaultCacheAwareContextLoaderDelegate.java:99) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate.java:117) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.test.context.support.DefaultTestContext.getApplicationContext(DefaultTestContext.java:108) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.injectDependencies(DependencyInjectionTestExecutionListener.java:118) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.test.context.support.DependencyInjectionTestExecutionListener.prepareTestInstance(DependencyInjectionTestExecutionListener.java:83) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener.prepareTestInstance(SpringBootDependencyInjectionTestExecutionListener.java:44) [spring-boot-test-autoconfigure-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.test.context.TestContextManager.prepareTestInstance(TestContextManager.java:246) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.test.context.junit.jupiter.SpringExtension.postProcessTestInstance(SpringExtension.java:97) [spring-test-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeTestInstancePostProcessors$5(ClassTestDescriptor.java:349) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.JupiterTestDescriptor.executeAndMaskThrowable(JupiterTestDescriptor.java:215) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$invokeTestInstancePostProcessors$6(ClassTestDescriptor.java:349) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:195) [?:?]
at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) [?:?]
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1492) [?:?]
at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) [?:?]
at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) [?:?]
at java.util.stream.StreamSpliterators$WrappingSpliterator.forEachRemaining(StreamSpliterators.java:312) [?:?]
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:735) [?:?]
at java.util.stream.Streams$ConcatSpliterator.forEachRemaining(Streams.java:734) [?:?]
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:658) [?:?]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.invokeTestInstancePostProcessors(ClassTestDescriptor.java:348) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.instantiateAndPostProcessTestInstance(ClassTestDescriptor.java:270) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstanceProvider$2(ClassTestDescriptor.java:259) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstanceProvider$3(ClassTestDescriptor.java:263) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at java.util.Optional.orElseGet(Optional.java:358) [?:?]
at org.junit.jupiter.engine.descriptor.ClassTestDescriptor.lambda$testInstanceProvider$4(ClassTestDescriptor.java:262) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:82) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.prepare(TestMethodTestDescriptor.java:59) [junit-jupiter-engine-5.3.0.jar:5.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$prepare$1(NodeTestTask.java:116) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.prepare(NodeTestTask.java:116) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:102) [junit-platform-engine-1.3.0.jar:1.3.0]
at java.util.ArrayList.forEach(ArrayList.java:1378) [?:?]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:127) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:107) [junit-platform-engine-1.3.0.jar:1.3.0]
at java.util.ArrayList.forEach(ArrayList.java:1378) [?:?]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:136) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:72) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:127) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:107) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:52) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) [junit-platform-engine-1.3.0.jar:1.3.0]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:220) [junit-platform-launcher-1.3.0.jar:1.3.0]
at org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$6(DefaultLauncher.java:188) [junit-platform-launcher-1.3.0.jar:1.3.0]
at org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:202) [junit-platform-launcher-1.3.0.jar:1.3.0]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:181) [junit-platform-launcher-1.3.0.jar:1.3.0]
at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:128) [junit-platform-launcher-1.3.0.jar:1.3.0]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invokeAllTests(JUnitPlatformProvider.java:142) [surefire-junit-platform-2.22.0.jar:2.22.0]
at org.apache.maven.surefire.junitplatform.JUnitPlatformProvider.invoke(JUnitPlatformProvider.java:117) [surefire-junit-platform-2.22.0.jar:2.22.0]
at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:383) [surefire-booter-2.22.0.jar:2.22.0]
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:344) [surefire-booter-2.22.0.jar:2.22.0]
at org.apache.maven.surefire.booter.ForkedBooter.execute(ForkedBooter.java:125) [surefire-booter-2.22.0.jar:2.22.0]
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:417) [surefire-booter-2.22.0.jar:2.22.0]
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.1.0.RELEASE.jar:5.1.0.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:179) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:98) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:90) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:66) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:304) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:439) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:379) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:303) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:261) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:220) ~[spring-boot-2.1.0.M4.jar:2.1.0.M4]
... 86 more
Comment From: blake-bauman
Seems that when adding a @TestPropertySource
to those tests, and adding a dummy logging property logging.level.some.logger.name=INFO
, this issue goes away.
Comment From: wilkinsona
Can you please provide a small sample (something we can unzip or git clone
) that reproduces the behaviour you've described? We have plenty of tests and samples that use @SpringBootTest
with no logging levels configured that do not fail in the way you've described so I suspect there may be a little more to this.
Comment From: blake-bauman
I'm working on one, trying to whittle the complicated project down to something simple that can be shared. I'm beginning to wonder if it has to do with one of the dependencies being included.
Comment From: blake-bauman
Created a simple project which really does nothing but start up a simple test, and I can get the error.
Comment From: snicoll
@blake-bauman this sample project works for me and there is no reference to logging.level
(it is also fairly complicated so you may want to trim the dependencies down).
Comment From: blake-bauman
@snicoll
Right. The problem is I get the above error without ever defining logging.level
. It's as if some combination of dependencies plus the environment is causing logging.level
to be initialized as an empty String instead of null. Which, in turn, causes the error that the String can't be converted to a Map. While some environments seem to work, building in Jenkins has a 100% failure.
What fixes the issue:
* Defining a @TestPropertySource
with a classpath resource which defines logging.level for a random logger.
* Defining a @TestPropertySource
with a file resource (even if logging.level is not defined)
It's very bizarre. I'll whittle the dependencies down further to see if I can isolate the culprit. Are there any options I can set that might help me locate the problem?
Comment From: wilkinsona
I would guess that something on Jenkins is setting a logging.level property with a string value. For example, the following will fail:
LOGGING_LEVEL=boom java -jar target/demo-0.0.1-SNAPSHOT.jar
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:364) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:323) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at com.example.demo.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [demo-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.9.RELEASE.jar!/:5.0.9.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:162) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:67) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:305) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:441) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:381) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:304) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:262) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) ~[spring-boot-2.0.5.RELEASE.jar!/:2.0.5.RELEASE]
... 26 common frames omitted
The app in this case is a barebones Spring Boot 2.0.5 app that depends on spring-boot-starter
and nothing else.
Comment From: blake-bauman
I get that, and I'm chasing this down with the Jenkins team to see if there's any weird properties or environment variables being set.
However, the problem goes away in this same job when downgrading to Spring Boot 2.0.5 (and Spring to 5.0.8).
I've reduced the dependencies down to the minimal in the test project.
Comment From: wilkinsona
However, the problem goes away in this same job when downgrading to Spring Boot 2.0.5 (and Spring to 5.0.8).
That's surprising. I see the failure with 2.0.5 as shown in the stack trace above. It also fails with 2.0.4:
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map<java.lang.String, java.lang.String>
at org.springframework.boot.context.properties.bind.Binder.handleBindError(Binder.java:250) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:226) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:210) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:166) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.setLogLevels(LoggingApplicationListener.java:307) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.initializeFinalLoggingLevels(LoggingApplicationListener.java:290) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.initialize(LoggingApplicationListener.java:238) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEnvironmentPreparedEvent(LoggingApplicationListener.java:200) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.logging.LoggingApplicationListener.onApplicationEvent(LoggingApplicationListener.java:173) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:127) ~[spring-context-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.boot.context.event.EventPublishingRunListener.environmentPrepared(EventPublishingRunListener.java:74) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.SpringApplicationRunListeners.environmentPrepared(SpringApplicationRunListeners.java:54) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.prepareEnvironment(SpringApplication.java:361) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1258) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1246) [spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at com.example.loggingleveltest.DemoApplication.main(DemoApplication.java:10) [classes!/:0.0.1-SNAPSHOT]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_181]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_181]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_181]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_181]
at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:48) [logging-level-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:87) [logging-level-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.Launcher.launch(Launcher.java:50) [logging-level-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
at org.springframework.boot.loader.JarLauncher.main(JarLauncher.java:51) [logging-level-test-0.0.1-SNAPSHOT.jar:0.0.1-SNAPSHOT]
Caused by: org.springframework.core.convert.ConverterNotFoundException: No converter found capable of converting from type [java.lang.String] to type [java.util.Map<java.lang.String, java.lang.String>]
at org.springframework.core.convert.support.GenericConversionService.handleConverterNotFound(GenericConversionService.java:321) ~[spring-core-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.core.convert.support.GenericConversionService.convert(GenericConversionService.java:194) ~[spring-core-5.0.8.RELEASE.jar!/:5.0.8.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter$CompositeConversionService.convert(BindConverter.java:162) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:96) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.BindConverter.convert(BindConverter.java:88) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.MapBinder.bindAggregate(MapBinder.java:67) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.AggregateBinder.bind(AggregateBinder.java:58) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.lambda$bindAggregate$2(Binder.java:305) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder$Context.withIncreasedDepth(Binder.java:441) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder$Context.access$100(Binder.java:381) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bindAggregate(Binder.java:304) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bindObject(Binder.java:262) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
at org.springframework.boot.context.properties.bind.Binder.bind(Binder.java:221) ~[spring-boot-2.0.4.RELEASE.jar!/:2.0.4.RELEASE]
... 26 common frames omitted
If you don't see a failure with 2.0.4, but do see one with 2.1.0.M4, then there's more to this than you've currently described. If you'd like us to make some more progress on this we're going to need a sample that works with 2.0.4 and fails with 2.1.0.M4.
Comment From: blake-bauman
Where is your stack trace coming from? It's not what I pasted. I understand that you got it to fail by doing something that we are not, but that doesn't mean it's the same cause for my problem. And it certainly doesn't mean that I'm not seeing what I'm seeing.
Using the sample I provided, this succeeds:
<version.spring>5.0.8.RELEASE</version.spring>
<version.spring.boot>2.0.5.RELEASE</version.spring.boot>
This fails:
<version.spring>5.1.0.RELEASE</version.spring>
<version.spring.boot>2.1.0.M4</version.spring.boot>
I get that you can't recreate this. There may be more to this than I've described, but literally, the above change is the only change I need to make to trigger the failure. I don't know enough about the internal "magic" of Spring Boot to know where to begin looking. I certainly don't know what changed between these versions to know what possible environmental effect has triggered the failure in the new release, but didn't trigger the failure in the prior one. The job may be configured incorrectly and needs fixing, but the versioning above is the only change between successful and unsuccessful builds.
Since this failure happens so early and involves initializing logging, adding logging statements have proven ineffective. Given that the version is the only change, I'm looking for ideas of where to look so I can help track down what specific change triggered the issue.
Comment From: wilkinsona
I didn't suggest that you were not seeing what you thought you were seeing. All I said was that I think there's more to this than currently described. Specifically, my current best guess is that you have a property named logger.level
set in the environment where it's failing. However, if it were that simple, you would see the failure with Boot 2.0.4, 2.0.5, and 2.1.0.M4 because, as shown in the stack traces in my comments above, they all behave in the same way when logger.level
is set.
If, when you reproduce the problem, you're in a position to attach a debugger, I'd take a look at the Environment
in LoggingApplicationListener.setLogLevels(LoggingSystem, Environment)
and see what property sources it contains and what values each of those sources contains.
Comment From: blake-bauman
Ok thanks. Will do.
Comment From: spring-projects-issues
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Comment From: blake-bauman
So far, I've been unable to recreate this in an environment where I can attach a debugger. I'll keep looking for what's special about Jenkins here.
Comment From: blake-bauman
So, not sure what changed, but I updated the test project to Spring 5.1.1 (from 5.1.0) and SB 2.1.0.RC1 (from 2.1.0.M4), and the problem is fixed.
I definitely can't explain it.
Comment From: bclozel
I'm closing this for now since we can't reproduce this anymore.
Comment From: dmccorm2
I've experienced this same issue, except on Spring Boot 2.1.2 (on application start). I'm using the log4j2 starter just for some additional context: if I use a system environmental variable LOGGING_LEVEL it throws the above error. If I add log.level.[name] to the application.properties this error goes away but my log4j2.xml is ignored. Once I remove LOGGING_LEVEL as an environmental variable I can remove log.level from properties and spring logging will respect my log4j2.xml. Also per the documentation it says I can use log4j2-spring.xml, however, that no longer appears to be working.
Comment From: wilkinsona
if I use a system environmental variable
LOGGING_LEVEL
it throws the above error
That is to be expected and is what I suspect was causing the problem reported above.
If I add
log.level.[name]
to theapplication.properties
this error goes away but my log4j2.xml is ignored
I guess you mean logging.level.[name]
? Adding such a property should not cause your log4j2.xml to be ignored. If that's happening, it's different problem to the one that was reported here. If you would like us to investigate, please open a new issue with a minimal and complete example that reproduces the problem. That should be in the form of a zip attached to the issue or a separate repository that we can clone.
Comment From: dmccorm2
Yes. logging.level.[name]. Basically if that's defined in application.properties for example, logging.level.root, it overrides the Root entry in log4j2.xml. My concern isn't really trying to reconcile the properties between application.properties and log4j2.xml, I just didn't see this behavior in Spring Boot 1.5 with the environmental variable LOGGING_LEVEL causing the properties exception. Looks like I just missed the Configuration section in the migration guide. My mistake, appreciate the help (if anyone else has this issue): https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0 : LOGGING_LEVEL translated to logging.level for spring which requires logging.level.[name].
Comment From: distributev
I used the below trick explained here.
There's a nice little hack to trigger a context refresh - to use org.springframework.cloud.context.refresh.ContextRefresher
https://stackoverflow.com/questions/24720330/reload-or-refresh-a-spring-application-context-inside-a-test-method
On the latest Spring Boot stable release + the latest version of org.springframework.cloud available on the Maven repository I get the same exception when I use the
at org.springframework.cloud.context.refresh.ContextRefresher.refresh(ContextRefresher.java:83)
Here is the stacktrace
org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'logging.level' to java.util.Map
With the same logging configuration in the yml file the normal spring boot apps starts fine (this is not using cloud.context.refresh.ContextRefresher.refresh) but in the JUnit 5 which is using cloud.context.refresh.ContextRefresher.refresh the error is happening.
Then I tried another test in which I removed all the logging related configuration from the yml file and the normal spring boot app continued to start without any error and the JUnit 5 test which is using cloud.context.refresh.ContextRefresher.refresh continued to fail with the same exception (even when all the logging related configurations were removed from the yml file).