2009/5/26 Jon Pearson <jon.pear...@sixnet.com>:
> I'm having some trouble getting classes loaded by a new classloader to
> be able to see classes which should have been loaded automatically from
> WEB-INF/lib. All of the documentation that I've seen so far (FAQs,
> mailing list searches, ...) describe problems that people have had using
> the standard classloader that Tomcat provides, but I have yet to see one
> dealing with dynamically loading classes from a new classloader defined
> within a webapp.
>
> More specifically, here is my problem:
>
> I am developing an application suite involving a database backend which
> feeds and is updated by server processes and a Web UI. To support
> multiple databases, database modules (JAR files) can simply be dropped
> in and loaded by each application dynamically.
>
> The problem is that when the Web UI loads the database module, that
> module is unable to actually load the JDBC driver
> (org.postgresql.Driver) which is packaged in
> WEB-INF/lib/postgresql-8.3-604.jdbc4.jar (I've checked the case of the
> path components).
>
> This is definitely related to classloaders; I tried placing the database
> module directly into my WAR file under
> WEB-INF/classes/package/name/PostgreSQLDatabale.class and it worked. But
> if I do that, I lose the modularity and easy-upgrading that I achieved
> by going with the dynamic loading of classes from JARs.
>
> I'm using java.net.URLClassLoader with the parent classloader set to the
> classloader that loaded my application classes, so it should
> theoretically be the same classloader used to load the
> postgresql-8.3-604.jdbc4.jar file.
>
> Has anyone else encountered a problem like this? Any suggestions on what
> else I should try? Thanks in advance!
>
> Jonathan P. Pearson - Software Engineer
> --------------------------------------------------

1. What tomcat version?

2. The documentation on classloaders is here:
http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html

3. Some JDBC drivers use native code. Those cannot be loaded from
different class loaders in the same time. Thus, they cannot be loaded
from /WEB-INF/lib, as there will be conflicts between applications,
or between several instances of the same application if it is restarted.

4. Put the jar file into WEB-INF/lib, and then restart your web application.
 (E.g., using Tomcat Manager).  Your jar library will be loaded.
http://tomcat.apache.org/tomcat-6.0-doc/html-manager-howto.html
http://tomcat.apache.org/tomcat-6.0-doc/manager-howto.html

Best regards,
Konstantin Kolinko

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

Reply via email to