tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Richard Troy <>
Subject Re: regd classloader (fwd)
Date Thu, 15 Nov 2001 20:03:06 GMT
Date: Thu, 18 Oct 2001 08:08:03 -0700 (PDT)
From: Craig R. McClanahan <>
Subject: Re: regd classloader

On Thu, 18 Oct 2001, E B wrote:

> Date: Thu, 18 Oct 2001 10:28:27 +0100 (BST)
> From: E B <>
> Reply-To:
> To:,
> Subject: regd classloader
> Hi
> In tc4, whats the difference between "shared"
> and "common" class loader ? From the docs, I
> understand
> that from the webapp's point of view they are same.
> ie., they both give classes to all the webapps.
> Am I correct ?

The "shared" class loader is visible to all webapps, but NOT to Tomcat's
internal classes.

The "common" class loader is visible to all webapps AND to Tomcat's
internal classes.  A common scenario is where you wanted to use the same
JDBC driver for both a JDBCRealm implementation (so Tomcat needs access to
it) and one or more webapps.

> I want my webapp's classes to be visible and shared
> by a soap service. When I put my app's classes in
> shared dir my apache-soap's service could not find the
> app's classes. But it worked when I moved them to
> common/classes. So there seems to be something I am
> missing. what is it ?

The most likely cause is that you're trying to load classes from a "lower"
class loader in the hierarchy, which won't work.

Consider a simplified version of the hierarchy:

    Common  (package C)
    Shared  (package S)
    Webapp  (package W)

Now, consider what is visible to classes from each place:

* Classes in the Webapp class loader can see packages W, S, and C

* Classes in the Shared class loader can see packages S and C

* Classes in the Common class loader can see package C only.

In your scenario, it's likely that you had some class in the common
package that was trying to load your app's classes.  That won't work
unless the app's classes are also in the Common loader, OR unless the
service classes take advantage of the Context Class Loader mechanism to
get access to the webapp class loader for the current request:

  ClassLoader cl = Thread.currentThread().getContextClassLoader();
  Class clazz = cl.loadClass("W.Foo");


To unsubscribe:   <>
For additional commands: <>
Troubles with the list: <>

View raw message