Return-Path: X-Original-To: apmail-logging-commits-archive@minotaur.apache.org Delivered-To: apmail-logging-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 726A110BF0 for ; Tue, 15 Apr 2014 05:20:39 +0000 (UTC) Received: (qmail 30306 invoked by uid 500); 15 Apr 2014 05:20:39 -0000 Delivered-To: apmail-logging-commits-archive@logging.apache.org Received: (qmail 30286 invoked by uid 500); 15 Apr 2014 05:20:38 -0000 Mailing-List: contact commits-help@logging.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@logging.apache.org Delivered-To: mailing list commits@logging.apache.org Received: (qmail 30279 invoked by uid 99); 15 Apr 2014 05:20:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Apr 2014 05:20:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 15 Apr 2014 05:20:35 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 51026238890B; Tue, 15 Apr 2014 05:20:15 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1587421 - /logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java Date: Tue, 15 Apr 2014 05:20:15 -0000 To: commits@logging.apache.org From: mattsicker@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140415052015.51026238890B@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: mattsicker Date: Tue Apr 15 05:20:14 2014 New Revision: 1587421 URL: http://svn.apache.org/r1587421 Log: Use Loader.isClassAvailable. Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java Modified: logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java?rev=1587421&r1=1587420&r2=1587421&view=diff ============================================================================== --- logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java (original) +++ logging/log4j/log4j2/trunk/log4j-core/src/main/java/org/apache/logging/log4j/core/web/Log4jWebInitializerImpl.java Tue Apr 15 05:20:14 2014 @@ -26,6 +26,7 @@ import org.apache.logging.log4j.LogManag import org.apache.logging.log4j.core.LoggerContext; import org.apache.logging.log4j.core.config.Configurator; import org.apache.logging.log4j.core.helpers.FileUtils; +import org.apache.logging.log4j.core.helpers.Loader; import org.apache.logging.log4j.core.helpers.NetUtils; import org.apache.logging.log4j.core.impl.ContextAnchor; import org.apache.logging.log4j.core.impl.Log4jContextFactory; @@ -42,13 +43,10 @@ final class Log4jWebInitializerImpl impl private static final Object MUTEX = new Object(); static { - try { - Class.forName("org.apache.logging.log4j.core.web.JNDIContextFilter"); + if (Loader.isClassAvailable("org.apache.logging.log4j.core.web.JNDIContextFilter")) { throw new IllegalStateException("You are using Log4j 2 in a web application with the old, extinct " + "log4j-web artifact. This is not supported and could cause serious runtime problems. Please" + "remove the log4j-web JAR file from your application."); - } catch (final ClassNotFoundException ignore) { - /* Good. They don't have the old log4j-web artifact loaded. */ } } @@ -121,6 +119,7 @@ final class Log4jWebInitializerImpl impl } ContextAnchor.THREAD_CONTEXT.remove(); } else { + // won't it be amusing if the servlet container uses Log4j as its ServletContext logger? this.servletContext.log("Potential problem: Selector is not an instance of NamedContextSelector."); return; }