From be735356110a42e14546ebf92a0026e5181a16dc Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Wed, 12 Feb 2014 09:16:21 +0000 Subject: [PATCH] Defensive catch block in LogbackLoggingSystem Older versions of JBoss AS have a classpath clash with an older SLF4J (pre 1.6.5), so to prevent an app from blowing up on startup we defensively catch a NoSuchMethodError. Fixes gh-339 --- .../boot/logging/logback/LogbackLoggingSystem.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java index 9e4886236b2..e781666a491 100644 --- a/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java +++ b/spring-boot/src/main/java/org/springframework/boot/logging/logback/LogbackLoggingSystem.java @@ -67,7 +67,13 @@ public class LogbackLoggingSystem extends AbstractLoggingSystem { public void beforeInitialize() { super.beforeInitialize(); if (ClassUtils.isPresent("org.slf4j.bridge.SLF4JBridgeHandler", getClassLoader())) { - SLF4JBridgeHandler.removeHandlersForRootLogger(); + try { + SLF4JBridgeHandler.removeHandlersForRootLogger(); + } + catch (NoSuchMethodError e) { + // Method missing in older versions of SLF4J like in JBoss AS 7.1 + SLF4JBridgeHandler.uninstall(); + } SLF4JBridgeHandler.install(); } }