tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Class reloading
Date Thu, 19 Jul 2001 20:25:04 GMT
Miscellaneous updates embedded below, related to Tomcat 4.

On Thu, 19 Jul 2001, Bo Xu wrote:

> Reynir Hübner wrote:
> > does anyone know how this(note: Class-reloading) is in tomcat 4 ?
> >
> > thanx
> > -r
> > [...]
> Hi :-)
> * Servlet-auto-reloading in TC4.0b5
>    from my work,  Servlet-auto-reloading works well, but just from my
>    testing, if I put MyServlet in both:
>       - WEB-INF/classes (unpacked class-style)
>       - a jar file in WEB-INF/lib (packed jar-style)
>   then when I updated MyServlet in WEB-INF/classes, I can not auto-reload
>   the new one. I have posted a email to describe my testing several days
> ago.
>   in other cases, I can auto-reload MyServlet.

Tomcat 4.0-beta-5 did not deal with reloading from JAR files in
/WEB-INF/lib, whereas Tomcat 4.0-beta-6 (to be released soon) will.  I
haven't tried it with the same class in *both* places (that seems sort of
non-sensical to me :-), but I imagine it would only look at the version in
/WEB-INF/classes, because that is the one that the servlet spec requires
to be loaded first.

> * UtilityClassUsedByServlet-auto-reloading
>    I remember(?) it is same with the above

Yes, in Tomcat 4.0 it makes zero difference whether the modified class is
a servlet or not.  It only matters where the class is (and, of course, a
restart is only necessary if the class has ever been loaded in the first

> * Jsp-auto-reloading
>    I didn't test

Broken in beta-5, fixed in current nightly builds (for the last several
weeks) and in the upcoming beta-6.

Note - there is one scenario where JSP auto-reload might still not work
the way people expect (because it's not required by the spec, it's not yet
implemented in Tomcat 4).  If you are using the JSP include *directive*
(<%@ include file="foo.jsp" %>) in a page named "bar.jsp", and you change
"foo.jsp", the "bar.jsp" page will *not* be automatically regenerated.

> * UtilityClassUsedByJsp-auto-reloading
>    I didn't test

Same as utility class required by servlets.

> * reference email
>    ...
>    The one and only place from which automatic reloading will work is
>    unpacked classes in WEB-INF/classes of your own web app.  No changes
>    to any classes or JAR files *anywhere* else are recognized.

In beta-6, changes to a JAR file in /WEB-INF/lib will also be
detected.  But, no changes to classes loaded from anywhere other than
/WEB-INF/classes or /WEB-INF/lib will *ever* be detected and cause
automatic reload.  There are a bunch of technical reasons for this, too
tedious to go into here.

>    However, you can trigger a reload manually on any app -- whether or not
>    you've set the "reloadable" attribute -- by using the Manager
> application.

Still works.

NOTE:  no matter what reload mechanism you use, if you've changed a class
in the $CATALINA_HOME/lib directory (which is global to all webapps),
you'll still need to restart Tomcat for your apps to see the change.

Moral of the story - you should put your application classes inside
/WEB-INF/classes or /WEB-INF/lib  :-)

>    ...
>   Craig
> my understanding to above email is:
> - the 1st way for auto-reloading:
>   % first I need to set the "reloadable" attribute to "true" in
> conf/server.xml
>   % packed class(jar) will not be auto-reloaded, no matter whereever thay
> are
>   % only unpacked-classes(MyServlet, MyJSP?, MyUtility)  in WEB-INF/classes
>       can be auto-reloaded
> - the 2nd way for auto-reloading:
>    "by using the Manager application"
> Bo
> July 19, 2001
Craig McClanahan

View raw message