W3C home > Mailing lists > Public > www-jigsaw@w3.org > May to June 1999

Re: Access Error in Servlet

From: Santiago Gala <nostromo@bitmailer.es>
Date: Sat, 12 Jun 1999 17:17:13 -0400 (EDT)
To: dpwhite@halcyon.com
Cc: Benoit.Mahe@sophia.inria.fr, www-jigsaw@w3.org
Message-id: <3762CF68.DFE824E5@bitmailer.es>


"David P. White" wrote:

> Santiago Gala wrote:
> >
> > It is fairly obvious (I think):
> > A class can not call a protected method unless they are in the same package.
> > Two classes are never in the same package if they are loaded by different class loaders.
> > Jigsaw uses a special classloader for servlets in "/servlets". It uses the standard system loader for servlets called through ServletWrapper.
> >
> > If I'm right, that explains the behaviour you found.
> >
>
> Thanks for the response and the info. I guess what you say about
> different class loaders is true because it makes a certain amount of
> sense and I don't know any differently.
>
> I am still just a bit confused so please excuse my ignorance...
>
> I have tried placing my servlet's class file both directly in jigsaw's
> /servlet subdir and within a subdir under /servlet. The /servlet subdir
> has a servlet indexer. It appears that when I access the servlet,
> jigsaw's indexer automatically builds a servlet wrapper. On the server's
> console, I also get a message printed like "Create Servlet :
> foo.servlets.TestServlet.class". I had assumed that the servlet was
> therefore being loaded somehow from within the wrapper.
>
> So if:
>
> (1) I am correct about the server creating and then using the wrapper
> and
>
> (2) you are correct that the standard system loader is being used to
> load the servlet via the wrapper;
>

>From Jigsaw documentation:

How does Jigsaw load local servlet classes ?

    Jigsaw use a local ClassLoader to load servlet classes from the servlets Directory. If a servlet
    class is modified when Jigsaw is running, the ClassLoader load automatically the new class. It's a
    very useful feature for servlets developers.

    In the two first versions of Jigsaw2.0 (beta1 and beta2) this feature can be disabled because in
    some case the auto-reload feature could create some problems. In those versions there is a
    auto-reload flag in ServletWrapper.

    Now this problem has been resolved and we don't need the auto-reload flag anymore. But the
    auto-reload feature works only for the servlet classes located in the servlet directory. Servlets in the
    CLASSPATH are loaded by the system ClassLoader and their modified classes are not reloaded
    while the server is running.

So I think that the servlet is loaded with a local ClassLoader, but the support classes get loaded from the system class loader. Something that
could be interesting is to have a "jar wrapper", that takes a jar with a servlet and a bunch of support classes, but maintains the idea of
auto-reloading. I don't know if it is difficult to implement, but it would be handy for servlet development.



>
> Then why should there be an access error when the servlet attempts to
> create an instance of a class that is NOT located under /servlet but is
> elsewhere on the classpath passed to java when the server was started?
>
> Am I missing something?
>
> Cheers,
>
> David
Received on Saturday, 12 June 1999 20:01:45 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 9 April 2012 12:13:29 GMT