You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Kevin Jones <ke...@develop.com> on 2001/05/01 12:41:00 UTC

Servlet Re-loading in TC4

Tried this in user with no luck.

Re-loading doesn't work for me in TC4b3 - am I doing something stupid?

I have a context defined like this

<Context path="/AddressBook" docBase="AddressBook" debug="9"
reloadable="true">
   <Loader checkInterval="3"
classname="org.apache.catalina.loader.StandardLoader"/>
</Context>

The log says

StandardLoader[/AddressBook]: Reloading checks are enabled for this Context

but re-loading doesn't (appear) to work.

What have I missed?

Thanks,

Kevin Jones
DevelopMentor
www.develop.com


Re: Servlet Re-loading in TC4

Posted by Remy Maucherat <re...@betaversion.org>.
Quoting Martijn Koster <ma...@greenhills.co.uk>:

> On Tue, May 01, 2001 at 11:41:00AM +0100, Kevin Jones wrote:
> 
> > The log says
> > 
> > StandardLoader[/AddressBook]: Reloading checks are enabled for this
> Context
> > 
> > but re-loading doesn't (appear) to work.
> 
> Same problem here. The mailing list archives show others experience it
> too. I've appended a test which shows what's going on with the
> HelloWorld example.
> 
> The StandardClassLoader.findClass successfully loaded the servlet
> class from a "jndi:" URL, and then tried to convert that to a File so
> it can track modification dates. That file can't be found, and is
> therefore not cached, and therefore not tracked by modified(). You
> can't just convert a JNDI to a File pathname like that, AFAIK.
> 
> It seems to me that to support reloading StandardClassLoader should
> either use URLs and URLConnections only to load classes and track
> modification dates (not explicit File's), or else that the jndi URL
> should somehow be resolved into a file URL. At the very least
> findClass() could spot non-file URLs and not bother to do the File
> conversion, and instead log the fact that this repository cannot be
> tracked for modification to reduce recurring confusion.

Yes, I think that's probably the problem here. I'll implement the changes and 
see if it helps.

> But being completely new to Tomcat I may be completely off the mark,
> and certainly won't claim to know the right solution. :-) Can anyone
> enlighten us?

Remy

Re: Servlet Re-loading in TC4

Posted by Martijn Koster <ma...@greenhills.co.uk>.
On Tue, May 01, 2001 at 11:41:00AM +0100, Kevin Jones wrote:

> The log says
> 
> StandardLoader[/AddressBook]: Reloading checks are enabled for this Context
> 
> but re-loading doesn't (appear) to work.

Same problem here. The mailing list archives show others experience it
too. I've appended a test which shows what's going on with the
HelloWorld example.

The StandardClassLoader.findClass successfully loaded the servlet
class from a "jndi:" URL, and then tried to convert that to a File so
it can track modification dates. That file can't be found, and is
therefore not cached, and therefore not tracked by modified(). You
can't just convert a JNDI to a File pathname like that, AFAIK.

It seems to me that to support reloading StandardClassLoader should
either use URLs and URLConnections only to load classes and track
modification dates (not explicit File's), or else that the jndi URL
should somehow be resolved into a file URL. At the very least
findClass() could spot non-file URLs and not bother to do the File
conversion, and instead log the fact that this repository cannot be
tracked for modification to reduce recurring confusion.

But being completely new to Tomcat I may be completely off the mark,
and certainly won't claim to know the right solution. :-) Can anyone
enlighten us?

-- Martijn

Apply this patch:

Index: StandardClassLoader.java
===================================================================
RCS file: /home/cvspublic/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/loader/StandardClassLoader.java,v
retrieving revision 1.15
diff -u -r1.15 StandardClassLoader.java
--- StandardClassLoader.java	2001/04/25 04:14:47	1.15
+++ StandardClassLoader.java	2001/05/01 08:30:59
@@ -265,7 +265,7 @@
     /**
      * The debugging detail level of this component.
      */
-    protected int debug = 0;
+    protected int debug = 5;
 
 
     /**
@@ -695,6 +695,9 @@
                 name.replace('.', File.separatorChar) + ".class";
 	    try {
                 File file = new File(pathname);
+                if (debug >= 5)
+                    log("      Checking file " + pathname +
+                        " absolute path " + file.getAbsolutePath());
                 if (file.exists() && file.canRead()) {
                     if (debug >= 3)
                         log("    Caching from '" + file.getAbsolutePath() +

Then rebuild, do a:

  GET http://localhost:8080/examples/servlet/HelloWorldExample

and observe:

StandardClassLoader:   Loading class from parent
StandardClassLoader:       Checking repository jndi:/localhost/examples/WEB-INF/classes
StandardClassLoader:       Checking file jndi:/localhost/examples/WEB-INF/classes/HelloWorldExample.class absolute path /home/sss/tomcat-test/jndi:/localhost/examples/WEB-INF/classes/HelloWorldExample.class
StandardClassLoader:       Returning class class HelloWorldExample
StandardClassLoader:       Loaded by StandardClassLoader