-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Sreyan,

(Sorry, I sent way before I was done writing. Full intentional message
follows.)

On 2/18/15 10:15 AM, sreya...@gmail.com wrote:
> What is the SYSTEM PATH that you are referring to ? Is it the 
> JAVA_HOME or the PATH system variable ?

Neither of those. It's commonly referred to as the CLASSPATH
environment variable, which should pretty much never be set because
it's horribly confusing.

Instead, Tomcat uses "java -classpath [the classpath]" to launch the
JVM. The classpath used there includes two JAR files:

> bin/bootstrap.jar bin/tomcat-juli.jar

So the only thing that javax.sql.DriverManager can scan is the boot
classpath (that includes all the JVM internals) plus the system
classpath (which includes just those two specific JARs above).

> What is the CLASSPATH just before Tomcat properly starts up?

The boot class path includes JVM stuff (rt.jar, etc.)

The system class path includes anything the JVM environment was
instructed to load when launched (either from the CLASSPATH
environment variable, or from the "-classpath" argument on the
command-line).

Tomcat's bootstrap class creates a new ClassLoader which includes
everything in lib/*.jar and then starts the Tomcat container using
*that* as the effective "class path".

> What is it after it starts up?

Well, Tomcat can see everything in the boot and system class paths
(ClassLoaders) plus everything in lib/*.jar.

> Correct me if I am wrong that means that whatever dependencies I 
> have in my project is not added to the SYSTEM CLASSPATH but is 
> instead loaded by TOMCAT.

Correct.

> So if a module searches only the SYSTEM CLASSPATH it won’t be able
> to find the dependencies. Am I right ?

Correct. And DriverManager can't search *down* into ClassLoaders it
doesn't know about -- including Tomcat's ClassLoader. So,
DriverManager can't load your JDBC driver using its standard detection
algorithm.

So, you still need to call Class.forName to register the driver.

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1
Comment: GPGTools - http://gpgtools.org

iQIcBAEBCAAGBQJU5PrwAAoJEBzwKT+lPKRY0/kP/Raf7VLP18ZpzXlLqK+ehPW5
1tDiJAG/uiz9L+v3/cOgmqcabHI7m4BSGdd8eeW2G8CYNpjRYDRTjq8dGVPkkzO6
4ZR3CX2Hgawxw7Qg8hnDh+Fjq+o7yOclY9T0rQFzcP4UnS4cRnRDRHGZtADycP9Y
Fdgnq5ey/NloTYaUioAmdnL1wnj9pzhRkpzztI8fxhQ1q2AdkLojMUSOArlfg1X5
N/aSTA0ULhB8Socxiln6TSnjAMxoe2/1PCNwLcIzqLKJcN3zA2rt4eAf5F2JbC50
zJtfVNa5CEZa3W0Gj5Arl3YWp0rrBa/fNdv7j8iPoF7WZOJbACkZEYuQeS5U3SyS
kyPhKAkE0b5wICzT+H7VUkNCRi0Gb02ER+QFg/UnoYyX91HHJPKSXfPLmD1fraq0
YkrhmrXp2O7rRa7YiIDp0yL8d7tNppT7sObyzKzZ1TI7Bf5DXEFsx82aXXWQ7wO4
VOJh14CuaaBhmxWei3w+pUsoLxe359Fmj2cGbAjfCxGUqJhyZgltjMWCvagXM119
wg645c9nD71hpX1VpHiPQmougHB8a/w1ripd5hVwdT0NRnlYYG1oDKgT83dEYnkk
7yVnuGSA/upinWjdV+GjWCgLr1Kx8O0B4isX0yqBYXtQXh8m4/jDbFGx0V1mGFXW
aMQS15YHd+kU8oB65ioP
=sv9k
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to