"Sullivan, Craig R." wrote:

> [...]
> We're running JServ on a single server.  Won't all
> of our servlets get loaded by a single classloader?
> Additionally, if I move the helper classes outside
> of the servlets directory, they should all get loaded
> by a single classloader, also, right?     [...]

Hi :-)  I also have 2 similar questions:
          - how to load  helper class by the same ClassLoader?
          - how to force/prevent a ClassLoader to reload helper class ?


* from several emails in Servlet-List:
   if you move the helper classes outside of the servlets
  directory, and put them into CLASSPATH, it will "force"
  these helper classes loaded by SystemClassLoader,
  I guess now we can be sure that : all such helper classes
  will be loaded by the same ClassLoader(SystemClassLoader).

*
 -  from Servlet spec2.2-4.6 and spec2.3-3.6:
   ...
  Reloading Considerations
  Many servlet containers support servlet reloading for ease of development.
Reloading of servlet
  classes has been accomplished by previous generations of servlet containers
by creating a new class
  loader to load the servlet which is distinct from class loaders used to load
other servlets or the
  classes that they use in the servlet context. This can have the undesirable
side effect of causing
  object references within a servlet context to point at a different class or
object than expected which
  can cause unexpected behavior.
  Therefore, when a Container Provider implements a class reloading scheme for
ease of
  development, they must ensure that all servlets, and classes that they may
use, are loaded in the
  scope of a single class loader guaranteeing that the application will behave
as expected by the
  Developer.
  ...

  so IMO, the above means even if we put helper class inside
  of servlets directory, with spec2.2+, we still can be sure that
  all helper calsses will be loaded by the same ClassLoader(
  a custom ClassLoader used by Servlet container)


* if we move the helper classes outside of the servlets
  directory, and put them into Java_HOME/jre/lib/ext, it will
   "force" these helper classes loaded by ExtClassLoader.


* if we move the helper classes Inside of the servlets
  directory, and Also put them into CLASSPATH or
   Java_HOME/jre/lib/ext , I don't know which
   ClassLoader will load them, I just   guess:
     - if container does Not use "3 parameters Class.forName(...),
       I guess helper classes will be loaded by SystemClassLoader
       or ExtClassLoader
     - if container uses "3 parameters Class.forName(...),
       I guess helper classes will be loaded by custom ClassLoader


[*]  so from the above, I guess we can be sure that we can let helper
      classes loaded by the same ClassLoader.


* my question is:
      0  how to force/prevent reloading helper class ?

    - if helper classes are loaded by the only-one ClassLoader, but if
      at one moment(I suppose) , all the instances of myServlet
      class have been destroyed, and mySevlvet class has been
      unloaded,  now "all the possible refrences" to helper class
      within myServlet class have been lost,  so even if now
      the ClassLoader still hold a reference to a Class-object of
      helper classes, is it possible that the ClassLoader will
      "destroy" this Class-object?  and after ClassLoader
      "destroys" this Class-object, the static reference to
      the onlyOneInstance of helper classes(if helper class is also
      a SingleTon) will also be lost, and so this onlyOneInstance
      of helper classes will be destroyed.

   - if the above is right, now at this moment, all the reference to
     helper class are not there(and so the reference to the
     onlyOneInstance of helper class is also not there),
     so now is it possible that ClassLoader will "destroy"
     the Class-object to helper class? if so, and if I want,
     how can I prevent it?   because if I want to avoid
     open/reopen the DB connections many times, I don't
     want load/reload helper classes many times.

   - from several emails, if I put a reference to helper
      classes into "ServletContext", can I be sure that
      helper classes will not be unloaded? several emails
      give me this directions, I just want to make sure about
      it.

     - a similar question is: with Servlet spec 2.2+,  how to do
        the following:
       container uses a ClassLoader to load myServlet,
       then I modify myServlet and re-compile it, and after a while,
       the container finds the new version of myServlet  and try to
       reload it. now I if I follow spec 2.2+ and don't  make another
       ClassLoader to reload myServlet->I use the same ClassLoader
       to reload  myServlet, now my questions: how to "force" this
       ClassLoader to unload the old version of myServlet, and reload
       the new version of myServlet ?


Thanks in advance! :-)

Bo
Jan.25, 2001

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to