From cfa1c1e2e46bf1835c949f3c77bf5458452f631f Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 30 Nov 2012 07:56:38 +1100 Subject: [PATCH 1/2] 395394 allow logging from boot classloader --- .../src/main/java/org/eclipse/jetty/util/Loader.java | 1 - .../src/main/java/org/eclipse/jetty/util/log/Log.java | 4 ++-- .../org/eclipse/jetty/util/resource/Resource.java | 11 +---------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java index 2c25bfc4510..fed6bbcaddf 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/Loader.java @@ -47,7 +47,6 @@ public class Loader { /* ------------------------------------------------------------ */ public static URL getResource(Class loadClass,String name, boolean checkParents) - throws ClassNotFoundException { URL url =null; ClassLoader loader=Thread.currentThread().getContextClassLoader(); diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java index ab2486ea935..cf3030be4e6 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/log/Log.java @@ -91,7 +91,7 @@ public class Log * configuration of the Log class in situations where access to the System.properties are * either too late or just impossible. */ - URL testProps = Log.class.getClassLoader().getResource("jetty-logging.properties"); + URL testProps = Loader.getResource(Log.class,"jetty-logging.properties",true); if (testProps != null) { InputStream in = null; @@ -234,7 +234,7 @@ public class Log public static void setLogToParent(String name) { ClassLoader loader = Log.class.getClassLoader(); - if (loader.getParent()!=null) + if (loader!=null && loader.getParent()!=null) { try { diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java index 90944a1cb72..d9c525b1f29 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/resource/Resource.java @@ -298,16 +298,7 @@ public abstract class Resource implements ResourceFactory URL url=Resource.class.getResource(name); if (url==null) - { - try - { - url=Loader.getResource(Resource.class,name,checkParents); - } - catch(ClassNotFoundException e) - { - url=ClassLoader.getSystemResource(name); - } - } + url=Loader.getResource(Resource.class,name,checkParents); if (url==null) return null; return newResource(url,useCaches); From 61a0d48df49f09dd9645eb615c5d2d14bb60023c Mon Sep 17 00:00:00 2001 From: Greg Wilkins Date: Fri, 30 Nov 2012 08:33:56 +1100 Subject: [PATCH 2/2] 395394 allow logging from boot classloader --- .../eclipse/jetty/xml/XmlConfiguration.java | 37 ++++++++----------- 1 file changed, 15 insertions(+), 22 deletions(-) diff --git a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java index 66aa4ced6e2..5f71f28b31f 100644 --- a/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java +++ b/jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java @@ -117,30 +117,23 @@ public class XmlConfiguration private synchronized static XmlParser initParser() { XmlParser parser = new XmlParser(); - try - { - URL config60 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_6_0.dtd",true); - URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd",true); - parser.redirectEntity("configure.dtd",config76); - parser.redirectEntity("configure_1_0.dtd",config60); - parser.redirectEntity("configure_1_1.dtd",config60); - parser.redirectEntity("configure_1_2.dtd",config60); - parser.redirectEntity("configure_1_3.dtd",config60); - parser.redirectEntity("configure_6_0.dtd",config60); - parser.redirectEntity("configure_7_6.dtd",config76); + URL config60 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_6_0.dtd",true); + URL config76 = Loader.getResource(XmlConfiguration.class,"org/eclipse/jetty/xml/configure_7_6.dtd",true); + parser.redirectEntity("configure.dtd",config76); + parser.redirectEntity("configure_1_0.dtd",config60); + parser.redirectEntity("configure_1_1.dtd",config60); + parser.redirectEntity("configure_1_2.dtd",config60); + parser.redirectEntity("configure_1_3.dtd",config60); + parser.redirectEntity("configure_6_0.dtd",config60); + parser.redirectEntity("configure_7_6.dtd",config76); - parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config76); - parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config76); - parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config76); + parser.redirectEntity("http://jetty.mortbay.org/configure.dtd",config76); + parser.redirectEntity("http://jetty.eclipse.org/configure.dtd",config76); + parser.redirectEntity("http://www.eclipse.org/jetty/configure.dtd",config76); + + parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN",config76); + parser.redirectEntity("-//Jetty//Configure//EN",config76); - parser.redirectEntity("-//Mort Bay Consulting//DTD Configure//EN",config76); - parser.redirectEntity("-//Jetty//Configure//EN",config76); - } - catch (ClassNotFoundException e) - { - LOG.warn(e.toString()); - LOG.debug(e); - } return parser; }