From e5acb5fd66f951c01b5d224fb4409ffaac35ad56 Mon Sep 17 00:00:00 2001 From: kkolinko Date: Fri, 30 Apr 2010 03:49:40 +0000 Subject: [PATCH] Log unexpected runtima and IO errors in ApplicationContext#getResource() and ApplicationContext#getResourceAsStream(). This is inspired by BZ 49218. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@939551 13f79535-47bb-0310-9956-ffa450edef68 --- java/org/apache/catalina/core/ApplicationContext.java | 12 ++++++++++-- java/org/apache/catalina/core/LocalStrings.properties | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/java/org/apache/catalina/core/ApplicationContext.java b/java/org/apache/catalina/core/ApplicationContext.java index d25302e83..47b18b1e5 100644 --- a/java/org/apache/catalina/core/ApplicationContext.java +++ b/java/org/apache/catalina/core/ApplicationContext.java @@ -507,8 +507,12 @@ public class ApplicationContext return new URL ("jndi", "", 0, getJNDIUri(hostName, fullPath), new DirContextURLStreamHandler(resources)); - } catch (Exception e) { + } catch (NamingException e) { // Ignore + } catch (Exception e) { + // Unexpected + log(sm.getString("applicationContext.lookup.error", path, + getContextPath()), e); } } @@ -543,8 +547,12 @@ public class ApplicationContext Object resource = resources.lookup(normalizedPath); if (resource instanceof Resource) return (((Resource) resource).streamContent()); - } catch (Exception e) { + } catch (NamingException e) { // Ignore + } catch (Exception e) { + // Unexpected + log(sm.getString("applicationContext.lookup.error", path, + getContextPath()), e); } } return (null); diff --git a/java/org/apache/catalina/core/LocalStrings.properties b/java/org/apache/catalina/core/LocalStrings.properties index 2a774697b..65121ad98 100644 --- a/java/org/apache/catalina/core/LocalStrings.properties +++ b/java/org/apache/catalina/core/LocalStrings.properties @@ -30,6 +30,7 @@ applicationContext.addSessionCookieConfig.ise=Session Cookie configuration canno applicationContext.setSessionTracking.ise=The session tracking modes for context {0} cannot be set whilst the context is running applicationContext.setSessionTracking.iae.invalid=The session tracking mode {0} requested for context {1} is not supported by that context applicationContext.setSessionTracking.iae.ssl=The session tracking modes requested for context {1} included SSL and at least one other mode. SSL may not be configured with other modes. +applicationContext.lookup.error=Failed to locate resource [{0}] in context [{1}] applicationDispatcher.allocateException=Allocate exception for servlet {0} applicationDispatcher.deallocateException=Deallocate exception for servlet {0} applicationDispatcher.forward.ise=Cannot forward after response has been committed -- 2.11.0