Repository navigation
Closed
Labels
for: external-projectFor an external project and not something we can fix
Description
When I use Apache Commons BeanUtils with Spring Boot 2, I can't catch exception stacktrace message.
I also try other version, only 2.X have this problem.
build.gradle
buildscript {
ext {
springBootVersion = '2.0.0.RELEASE'
// springBootVersion = '1.5.10.RELEASE'
// springBootVersion = '2.0.1.BUILD-SNAPSHOT'
}
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-snapshot'
}
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
url 'https://repo.spring.io/libs-snapshot'
}
}
dependencies {
compile('org.springframework.boot:spring-boot-starter')
compile group: 'commons-beanutils', name: 'commons-beanutils', version: '1.9.3'
testCompile('org.springframework.boot:spring-boot-starter-test')
}
DemoApplication.java
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Bean
public CommandLineRunner run() {
return (args) -> {
throw new Exception("test");
};
}
}
Console
2018-03-13 11:03:05.166 INFO 22690 --- [ main] com.example.demo.DemoApplication : No active profile set, falling back to default profiles: default
2018-03-13 11:03:05.267 INFO 22690 --- [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@22f59fa: startup date [Tue Mar 13 11:03:05 CST 2018]; root of context hierarchy
2018-03-13 11:03:06.089 INFO 22690 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Registering beans for JMX exposure on startup
2018-03-13 11:03:06.103 INFO 22690 --- [ main] com.example.demo.DemoApplication : Started DemoApplication in 1.67 seconds (JVM running for 3.222)
Disconnected from the target VM, address: '127.0.0.1:63647', transport: 'socket'
Process finished with exit code 1
Reacted by mumutu66 and Dario Seidl
Metadata
Metadata
Assignees
Labels
for: external-projectFor an external project and not something we can fix
Activity
wilkinsona commentedon Mar 13, 2018
There are a few things going on here.
In 2.0,
SpringApplicationends up using aorg.apache.commons.logging.impl.Jdk14Loggerfor its logging which means that the logging isn't routed into Logback as it should be. In 1.5,SpringApplicationends up using anorg.apache.commons.logging.impl.SLF4JLogthat is provided by SLF4J and routes logging into Logback. This change has two causes.Firstly,
commons-loggingisn't on the classpath in 1.5 but it is in 2.0. This happens because we have removed the dependency management forcommons-beanutilsthat excludedcommons-logging. The problem can be avoided when using Boot 2.0 by excludingcommons-logging:commons-logging:However, that's not the full picture as the problem doesn't occur with 1.5 even when Commons Logging is on the classpath. In 1.5, Commons Logging's
LogFactoryfinds theMETA-INF/services/org.apache.commons.logging.LogFactoryfile injcl-over-slf4jandorg.apache.commons.logging.impl.SLF4JLogFactoryis used. In 2.0, we use Spring Framework'sspring-jclinstead ofjcl-over-slf4j.spring-jcldoes not contain aMETA-INF/services/org.apache.commons.logging.LogFactoryso Commons Logging falls back to its default factory and creates aorg.apache.commons.logging.impl.Jdk14Logger.I've opened SPR-16585 to see if
spring-jclcan be improved. In the meantime, please excludecommons-logging:commons-loggingas described above.alanbear commentedon Mar 14, 2018
Thank you for your help
erezwncare commentedon Dec 7, 2018
Seems like spring-jcl are not going to fix it... I also had my share of hidden Exception with this, as the following exception would not have been printed without the exclusion of the commons or adding a custom ApplicationRunListener :
Maybe something can be done on spring boot side ?