spring-projects / spring-boot

Spring Boot
https://spring.io/projects/spring-boot
Apache License 2.0
74.55k stars 40.54k forks source link

Incorrect application.yml causes Spring boot to exit without giving any proper information #12816

Closed RawSanj closed 6 years ago

RawSanj commented 6 years ago

Bug report:

Spring Boot 2.0.X exists without giving any proper error info when application.yml is invalid and spring-cloud-open-service-broker-starter-webmvc is on classpath.

Sample Application - boot-open-service-yaml-issue

Logs when running above Application:

14:43:36.639 [background-preinit] DEBUG org.jboss.logging - Logging Provider: org.jboss.logging.Log4j2LoggerProvider
14:43:36.655 [background-preinit] INFO org.hibernate.validator.internal.util.Version - HV000001: Hibernate Validator 6.0.9.Final
14:43:36.655 [background-preinit] DEBUG org.hibernate.validator.internal.engine.resolver.TraversableResolvers - Cannot find javax.persistence.Persistence on classpath. Assuming non JPA 2 environment. All properties will per default be traversable.
14:43:36.671 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - Trying to load META-INF/validation.xml for XML based Validator configuration.
14:43:36.671 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via TCCL
14:43:36.671 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ResourceLoaderHelper - Trying to load META-INF/validation.xml via Hibernate Validator's class loader
14:43:36.671 [background-preinit] DEBUG org.hibernate.validator.internal.xml.ValidationXmlParser - No META-INF/validation.xml found. Using annotation based configuration only.
14:43:36.921 [background-preinit] DEBUG org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator - Loaded expression factory via original TCCL
14:43:36.921 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator as ValidatorFactory-scoped message interpolator.
14:43:36.921 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.resolver.TraverseAllTraversableResolver as ValidatorFactory-scoped traversable resolver.
14:43:36.921 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.util.ExecutableParameterNameProvider as ValidatorFactory-scoped parameter name provider.
14:43:36.921 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.DefaultClockProvider as ValidatorFactory-scoped clock provider.
14:43:36.937 [background-preinit] DEBUG org.hibernate.validator.internal.engine.ValidatorFactoryImpl - HV000234: Using org.hibernate.validator.internal.engine.scripting.DefaultScriptEvaluatorFactory as ValidatorFactory-scoped script evaluator factory.

Process finished with exit code 1

Note:

I was going to create this Issue at spring-cloud-open-service-broker but when I update the Spring Boot version to 1,5,x I get the expected Invalid YAML error. So it seems to be Spring Boot 2.X issue occurring due to some auto-configuration in Spring Cloud Open Service Broker,

wilkinsona commented 6 years ago

Thanks for the sample. This is a duplicate of https://github.com/spring-projects/spring-boot/issues/12457. In this case, it's Spring Cloud Open Service Broker that's causing Commons Logging to get onto the class path:

[INFO] +- org.springframework.cloud:spring-cloud-open-service-broker-starter-webmvc:jar:2.0.0.M2:compile
[INFO] |  +- org.springframework.boot:spring-boot-starter-web:jar:2.0.1.RELEASE:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-json:jar:2.0.1.RELEASE:compile
[INFO] |  |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.9.5:compile
[INFO] |  |  |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.9.0:compile
[INFO] |  |  |  |  \- com.fasterxml.jackson.core:jackson-core:jar:2.9.5:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jdk8:jar:2.9.5:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.9.5:compile
[INFO] |  |  |  \- com.fasterxml.jackson.module:jackson-module-parameter-names:jar:2.9.5:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-tomcat:jar:2.0.1.RELEASE:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.29:compile
[INFO] |  |  |  +- org.apache.tomcat.embed:tomcat-embed-el:jar:8.5.29:compile
[INFO] |  |  |  \- org.apache.tomcat.embed:tomcat-embed-websocket:jar:8.5.29:compile
[INFO] |  |  +- org.hibernate.validator:hibernate-validator:jar:6.0.9.Final:compile
[INFO] |  |  |  +- javax.validation:validation-api:jar:2.0.1.Final:compile
[INFO] |  |  |  +- org.jboss.logging:jboss-logging:jar:3.3.2.Final:compile
[INFO] |  |  |  \- com.fasterxml:classmate:jar:1.3.4:compile
[INFO] |  |  +- org.springframework:spring-web:jar:5.0.5.RELEASE:compile
[INFO] |  |  |  \- org.springframework:spring-beans:jar:5.0.5.RELEASE:compile
[INFO] |  |  \- org.springframework:spring-webmvc:jar:5.0.5.RELEASE:compile
[INFO] |  |     +- org.springframework:spring-aop:jar:5.0.5.RELEASE:compile
[INFO] |  |     +- org.springframework:spring-context:jar:5.0.5.RELEASE:compile
[INFO] |  |     \- org.springframework:spring-expression:jar:5.0.5.RELEASE:compile
[INFO] |  \- org.springframework.cloud:spring-cloud-open-service-broker-autoconfigure:jar:2.0.0.M2:compile
[INFO] |     +- org.springframework.boot:spring-boot-starter-security:jar:2.0.1.RELEASE:compile
[INFO] |     |  +- org.springframework.security:spring-security-config:jar:5.0.4.RELEASE:compile
[INFO] |     |  |  \- org.springframework.security:spring-security-core:jar:5.0.4.RELEASE:compile
[INFO] |     |  \- org.springframework.security:spring-security-web:jar:5.0.4.RELEASE:compile
[INFO] |     \- org.springframework.cloud:spring-cloud-open-service-broker-core:jar:2.0.0.M2:compile
[INFO] |        \- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |           +- commons-logging:commons-logging:jar:1.2:compile
[INFO] |           \- commons-collections:commons-collections:jar:3.2.2:compile

Please open an issue against that project as they should not be pulling in Commons Logging as a transitive dependency.

Spring Framework's handling of Commons Logging polluting the classpath will be improved in SPR-16585.

Before these changes are available, you can work around the problem by excluding Commons Logging:

diff --git a/pom.xml b/pom.xml
index 489bee2..284a881 100644
--- a/pom.xml
+++ b/pom.xml
@@ -31,6 +31,12 @@
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-open-service-broker-starter-webmvc</artifactId>
             <version>2.0.0.M2</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>commons-logging</groupId>
+                    <artifactId>commons-logging</artifactId>
+                </exclusion>
+            </exclusions>
         </dependency>

         <dependency>