From: Oliver Jowett <oliver@opencloud.com>
To: Vadim Nasardinov <vadimn@redhat.com>
Cc: pgsql-jdbc@postgresql.org
Subject: Re: context classloader
Date: Sat, 22 Jan 2005 09:07:05 +1300
Message-ID: <41F160E9.3080506@opencloud.com> (raw)
In-Reply-To: <200501211022.50196@vadim.nasardinov>
References: <Pine.BSO.4.56.0501170706010.29112@leary.csoft.net>
<200501190957.26908@vadim.nasardinov>
<41EEC8E1.1010007@opencloud.com>
<200501211022.50196@vadim.nasardinov>
Vadim Nasardinov wrote:
> That part is predictable, yes. What's not predictable is which
> *particular* classloader this will be.
It is a different class of predictability. If you know where the driver
is loaded from, you know at least one location checked by the driver's
classloader -- the driver jar. You have no information about the CCL in
effect at driver load time, though.
>>You can always, for example, put driverconfig.properties in the path
>>of the same classloader that loads the driver
>
> Not always, you can't.
Why not? If you could put the driver jar there, why can't you also put
properties there?
>>In contrast, if you're relying on the CCL, you have essentially no
>>guarantees about where it will search. It could be a completely
>>unrelated CL that can't even see the driver jar!
>
> Why is that so terrible?
It's much less predictable. Given information on where the driver is
loaded from, you have no idea where it will load defaults from. At least
with using getClass().getClassLoader(), you know at least one location
(the driver jar's location), and can probably infer several more from
knowledge about how you configure classpaths to load the driver from.
> If one can put
> org/postgresql/driverconfig.properties on the same classpath as the
> driver, then, yes, they're all set. (Except for the bootstrap
> classloader case.) If they can't do that, then they're essentially in
> the same boat. How does one make sure that the classloader that loads
> org.postgresql.Driver is also the one that can find their
> driverconfig.properties?
Know your environment; supply a classpath for loading the driver that
includes a location that you can modify. e.g. add it to CLASSPATH, or
include it in the classpath-to-load-driver-from configuration, or put it
in the magic directory whose contents are included at startup, etc.
> I keep forgetting to ask. How do you put the driver in the bootstrap
> classpath? The only way that I know of is to use one of the following
> flags under Sun's JRE:
>
> -Xbootclasspath
> -Xbootclasspath/a
> -Xbootclasspath/p
>
> I was under the impression that using these is very uncommon.
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.
-O
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-jdbc@postgresql.org
Cc: oliver@opencloud.com, vadimn@redhat.com
Subject: Re: context classloader
In-Reply-To: <41F160E9.3080506@opencloud.com>
References: <Pine.BSO.4.56.0501170706010.29112@leary.csoft.net> <200501190957.26908@vadim.nasardinov> <41EEC8E1.1010007@opencloud.com> <200501211022.50196@vadim.nasardinov> <41F160E9.3080506@opencloud.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox