X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 41FCC3A55B5 for ; Mon, 24 Jan 2005 16:59:01 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 62754-01 for ; Mon, 24 Jan 2005 16:58:54 +0000 (GMT) Received: from mx1.redhat.com (mx1.redhat.com [66.187.233.31]) by svr1.postgresql.org (Postfix) with ESMTP id 6D4C23A55A1 for ; Mon, 24 Jan 2005 16:58:53 +0000 (GMT) Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id j0OGwqA8001266 for ; Mon, 24 Jan 2005 11:58:52 -0500 Received: from mail.boston.redhat.com (mail.boston.redhat.com [172.16.76.12]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id j0OGwpO08390 for ; Mon, 24 Jan 2005 11:58:51 -0500 Received: from vpn83-164.boston.redhat.com (vpn83-164.boston.redhat.com [172.16.83.164]) by mail.boston.redhat.com (8.12.8/8.12.8) with ESMTP id j0OGwpp5006286 for ; Mon, 24 Jan 2005 11:58:51 -0500 From: Vadim Nasardinov Organization: Red Hat / Westford To: pgsql-jdbc@postgresql.org Subject: Re: context classloader Date: Mon, 24 Jan 2005 11:59:31 -0500 User-Agent: KMail/1.7 References: <200501211022.50196@vadim.nasardinov> <41F160E9.3080506@opencloud.com> In-Reply-To: <41F160E9.3080506@opencloud.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200501241159.31793@vadim.nasardinov> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.025 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200501/229 X-Sequence-Number: 12109 To draw a line under this thread, here are my takeaways. The purpose of org/postgresql/driverconfig.properties is to globally configure the driver. The most consistent way to do this is to put the config file on the same path as the driver's .jar file. There are two distinct classes of users: (a) Those who have complete control over deployment of both the driver and the application that uses it. (b) Those who have limited control over their application's classpath. (For a recent example, see [1].) For Class A, the most consistent approach is to say, (a) Don't put pgsql-jdbc.jar on the boot classpath. No reason to do this. (b) If you want to configure the driver globally, put org/postgresql/driverconfig.properties in the same location as the pgsql-jdbc.jar file. For this class of users, then, the following works fine: if (getClass().getClassLoader() != null) { // load the config file } For Class B, the most consistent approach is to say, Since you don't have control over the driver's .jar file location, you're not meant to have control over its global settings. The same code works for this class of users as well. Defaulting to the system classloader strikes me as a fairly arbitrary way to avoid an NPE. I agree that using the context class loader is an equally arbitrary cop-out. On Friday 21 January 2005 15:07, Oliver Jowett wrote: > Well, the case that triggered this thread happened by putting the > driver jar in a particular directory that apparently was in the > appserver's bootstrap classpath. It's not common, but I don't see > why the driver should break if it happens. It shouldn't break. To prevent it from breaking, test the object for nullity before calling a method on it. Footnotes 1. http://archives.postgresql.org/pgsql-jdbc/2004-12/msg00212.php