Return-Path: X-Original-To: apmail-db-jdo-dev-archive@www.apache.org Delivered-To: apmail-db-jdo-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9E4499A40 for ; Fri, 2 Mar 2012 18:26:26 +0000 (UTC) Received: (qmail 17828 invoked by uid 500); 2 Mar 2012 18:26:26 -0000 Mailing-List: contact jdo-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jdo-dev@db.apache.org Delivered-To: mailing list jdo-dev@db.apache.org Received: (qmail 17820 invoked by uid 99); 2 Mar 2012 18:26:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Mar 2012 18:26:26 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [141.146.126.227] (HELO acsinet15.oracle.com) (141.146.126.227) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Mar 2012 18:26:17 +0000 Received: from acsinet22.oracle.com (acsinet22.oracle.com [141.146.126.238]) by acsinet15.oracle.com (Sentrion-MTA-4.2.2/Sentrion-MTA-4.2.2) with ESMTP id q22IPtmT025317 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Fri, 2 Mar 2012 18:25:56 GMT Received: from acsmt358.oracle.com (acsmt358.oracle.com [141.146.40.158]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id q22IPsAo017331 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 2 Mar 2012 18:25:55 GMT Received: from abhmt110.oracle.com (abhmt110.oracle.com [141.146.116.62]) by acsmt358.oracle.com (8.12.11.20060308/8.12.11) with ESMTP id q22IPsAk001999 for ; Fri, 2 Mar 2012 12:25:54 -0600 Received: from [192.168.0.10] (/69.181.138.81) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 02 Mar 2012 10:25:54 -0800 Message-Id: <47ED59DE-4868-448D-90D1-D8349512C492@oracle.com> From: Craig L Russell To: "jdo-dev@db.apache.org project" Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Subject: log4j class loader Mime-Version: 1.0 (Apple Message framework v936) Date: Fri, 2 Mar 2012 10:25:52 -0800 X-Mailer: Apple Mail (2.936) X-Source-IP: acsinet22.oracle.com [141.146.126.238] X-Auth-Type: Internal IP X-CT-RefId: str=0001.0A090206.4F5110B4.0054,ss=1,re=0.000,fgs=0 X-Virus-Checked: Checked by ClamAV on apache.org It looks like log4j looks in the class loader that loads the log4j classes [1], so putting the configuration file directory in the class loader used to load log4j should work. I looked in Enhance.java and couldn't quite figure out where the log4j jar file is being added to the class path. URL[] classPathURLs = new URL[2]; ArrayList cpList = new ArrayList(); ClassLoader loader = null; try { cpList.add((new File(enhancedIdDirName)).toURI().toURL()); cpList.add((new File(fromDirName)).toURI().toURL()); String[] jars = {"jar"}; if (impl.equals("iut")) { fi = FileUtils.iterateFiles(new File(iutLibsDirectory), jars, true); while (fi.hasNext()) { cpList.add(fi.next().toURI().toURL()); } } loader = new URLClassLoader(cpList.toArray(classPathURLs), getClass().getClassLoader()); // Utilities.printClasspath(loader); } catch (MalformedURLException ex) { Logger.getLogger(Enhance.class.getName()).log(Level.SEVERE, null, ex); } Actually, I can't figure out where DataNucleus and log4j are being added to the class path of the loader. Craig [1] sources from log4j /** 69 This method will search for resource in different 70 places. The search order is as follows: 71 72
    73 74

  1. Search for resource using the thread context 75 class loader under Java2. If that fails, search for 76 resource using the class loader that loaded this 77 class (Loader). Under JDK 1.1, only the the class 78 loader that loaded this class (Loader) is used. 79 80

  2. Try one last time with 81 ClassLoader.getSystemResource(resource), that is is 82 using the system class loader in JDK 1.2 and virtual machine's 83 built-in class loader in JDK 1.1. 84 85
86 */ 87 static public URL getResource(String resource) { 88 ClassLoader classLoader = null; 89 URL url = null; 90 91 try { 92 if(!java1 && !ignoreTCL) { 93 classLoader = getTCL(); 94 if(classLoader != null) { 95 LogLog.debug("Trying to find ["+resource+"] using context classloader " 96 +classLoader+"."); 97 url = classLoader.getResource(resource); 98 if(url != null) { 99 return url; 100 } 101 } 102 } 103 104 // We could not find resource. Ler us now try with the 105 // classloader that loaded this class. 106 classLoader = Loader.class.getClassLoader(); 107 if(classLoader != null) { 108 LogLog.debug("Trying to find ["+resource+"] using "+classLoader 109 +" class loader."); 110 url = classLoader.getResource(resource); 111 if(url != null) { 112 return url; 113 } 114 } 115 } catch(IllegalAccessException t) { 116 LogLog.warn(TSTR, t); 117 } catch(InvocationTargetException t) { 118 if (t.getTargetException() instanceof InterruptedException 119 || t.getTargetException() instanceof InterruptedIOException) { 120 Thread.currentThread().interrupt(); 121 } 122 LogLog.warn(TSTR, t); 123 } catch(Throwable t) { 124 // 125 // can't be InterruptedException or InterruptedIOException 126 // since not declared, must be error or RuntimeError. 127 LogLog.warn(TSTR, t); 128 } 129 130 // Last ditch attempt: get the resource from the class path. It 131 // may be the case that clazz was loaded by the Extentsion class 132 // loader which the parent of the system class loader. Hence the 133 // code below. 134 LogLog.debug("Trying to find ["+resource+ 135 "] using ClassLoader.getSystemResource()."); 136 return ClassLoader.getSystemResource(resource); 137 } 138 13 Craig L Russell Architect, Oracle http://db.apache.org/jdo 408 276-5638 mailto:Craig.Russell@oracle.com P.S. A good JDO? O, Gasp!