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/04 09:56:14 UTC

class reloading

I can't get servlet re-loading to work in TC4b3. Looking at the code -

Loader creates a thread that sleeps until the time set in server.xml
expires. This thread calls StandardClassLoader.modified

The modified call checks the classCache to see if there are any entries
(code is here)

if (classCache.size() < 1)
{
    return (false);
}

Checking through the code classes are added to the cache in the loadClass
function.

Near the end of that function is this code

try
{
    File file = new File(pathname);
    if (file.exists() && file.canRead())
    {
        if (debug >= 3)
        {
            log("    Caching from '" + file.getAbsolutePath() +
                "' modified '" +
                (new java.sql.Timestamp(file.lastModified())) +
                "'");
        }
        classCache.put(name, new ClassCacheEntry(clazz, file,
file.lastModified()));
    }
} catch(AccessControlException ace)

Printing out the value of 'pathname' just before this code executes gives

"jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\lab\Browse
.class",

which means that the 'file' doesn't exist and so doesn't get added to the
cache.

Should that 'jndi:/localhost' be there ?

This is with the latest nightly build BTW,

Kevin Jones
DevelopMentor
www.develop.com


RE: class reloading

Posted by Kevin Jones <ke...@develop.com>.
Thanks Craig,

I'll download the latest nightly and try it.


BTW - I've just sent another reply to my original message - please ignore
that - I hadn't seen this reply then, my apologies,

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: Craig R. McClanahan [mailto:craigmcc@apache.org]
> Sent: 04 May 2001 20:00
> To: Tomcat-Dev
> Subject: Re: class reloading
>
>
>
>
> On Fri, 4 May 2001, Kevin Jones wrote:
>
> > I can't get servlet re-loading to work in TC4b3. Looking at the code -
> >
> > Loader creates a thread that sleeps until the time set in server.xml
> > expires. This thread calls StandardClassLoader.modified
> >
> > The modified call checks the classCache to see if there are any entries
> > (code is here)
> >
> > if (classCache.size() < 1)
> > {
> >     return (false);
> > }
> >
> > Checking through the code classes are added to the cache in the
> loadClass
> > function.
> >
> > Near the end of that function is this code
> >
> > try
> > {
> >     File file = new File(pathname);
> >     if (file.exists() && file.canRead())
> >     {
> >         if (debug >= 3)
> >         {
> >             log("    Caching from '" + file.getAbsolutePath() +
> >                 "' modified '" +
> >                 (new java.sql.Timestamp(file.lastModified())) +
> >                 "'");
> >         }
> >         classCache.put(name, new ClassCacheEntry(clazz, file,
> > file.lastModified()));
> >     }
> > } catch(AccessControlException ace)
> >
> > Printing out the value of 'pathname' just before this code
> executes gives
> >
> >
> "jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\
> lab\Browse
> > .class",
> >
> > which means that the 'file' doesn't exist and so doesn't get
> added to the
> > cache.
> >
> > Should that 'jndi:/localhost' be there ?
> >
> > This is with the latest nightly build BTW,
> >
>
> By "latest", do you mean 20010503?  The reason I ask is that Remy made
> some changes yesterday that would have shown up in the 20010504 build, and
> these changes fixed class reloading at least for the use case reported in
> the bug report (i.e. load one of the example app servlets, then recompile
> it).  The changes were specifically in the code area you describe above.
>
> > Kevin Jones
> > DevelopMentor
> > www.develop.com
> >
> >
>
> Craig
>
>


Re: class reloading

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Fri, 4 May 2001, Kevin Jones wrote:

> I can't get servlet re-loading to work in TC4b3. Looking at the code -
> 
> Loader creates a thread that sleeps until the time set in server.xml
> expires. This thread calls StandardClassLoader.modified
> 
> The modified call checks the classCache to see if there are any entries
> (code is here)
> 
> if (classCache.size() < 1)
> {
>     return (false);
> }
> 
> Checking through the code classes are added to the cache in the loadClass
> function.
> 
> Near the end of that function is this code
> 
> try
> {
>     File file = new File(pathname);
>     if (file.exists() && file.canRead())
>     {
>         if (debug >= 3)
>         {
>             log("    Caching from '" + file.getAbsolutePath() +
>                 "' modified '" +
>                 (new java.sql.Timestamp(file.lastModified())) +
>                 "'");
>         }
>         classCache.put(name, new ClassCacheEntry(clazz, file,
> file.lastModified()));
>     }
> } catch(AccessControlException ace)
> 
> Printing out the value of 'pathname' just before this code executes gives
> 
> "jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\lab\Browse
> .class",
> 
> which means that the 'file' doesn't exist and so doesn't get added to the
> cache.
> 
> Should that 'jndi:/localhost' be there ?
> 
> This is with the latest nightly build BTW,
> 

By "latest", do you mean 20010503?  The reason I ask is that Remy made
some changes yesterday that would have shown up in the 20010504 build, and
these changes fixed class reloading at least for the use case reported in
the bug report (i.e. load one of the example app servlets, then recompile
it).  The changes were specifically in the code area you describe above.

> Kevin Jones
> DevelopMentor
> www.develop.com
> 
> 

Craig



RE: class reloading

Posted by "Craig R. McClanahan" <cr...@apache.org>.

On Mon, 7 May 2001, Kevin Jones wrote:

> > Printing out the value of 'pathname' just before this code executes gives
> >
> > "jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\
> > lab\Browse
> > .class",
> >
> > which means that the 'file' doesn't exist and so doesn't get added to the
> > cache.
> >
> > Should that 'jndi:/localhost' be there ?
> 
> I take it from the silence that this behaviour is expected and that I should
> not be able to do any reloading?
> 

Remy answered with some patches, and I asked last week if that fixed the
reloading for you.  Have you tried it with the latest nightly builds?

> Kevin Jones
> DevelopMentor
> www.develop.com
> 

Craig


RE: class reloading

Posted by Kevin Jones <ke...@develop.com>.
> Printing out the value of 'pathname' just before this code executes gives
>
> "jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\
> lab\Browse
> .class",
>
> which means that the 'file' doesn't exist and so doesn't get added to the
> cache.
>
> Should that 'jndi:/localhost' be there ?

I take it from the silence that this behaviour is expected and that I should
not be able to do any reloading?

Kevin Jones
DevelopMentor
www.develop.com

> -----Original Message-----
> From: Kevin Jones [mailto:kevinj@develop.com]
> Sent: 04 May 2001 08:56
> To: Tomcat-Dev
> Subject: class reloading
>
>
> I can't get servlet re-loading to work in TC4b3. Looking at the code -
>
> Loader creates a thread that sleeps until the time set in server.xml
> expires. This thread calls StandardClassLoader.modified
>
> The modified call checks the classCache to see if there are any entries
> (code is here)
>
> if (classCache.size() < 1)
> {
>     return (false);
> }
>
> Checking through the code classes are added to the cache in the loadClass
> function.
>
> Near the end of that function is this code
>
> try
> {
>     File file = new File(pathname);
>     if (file.exists() && file.canRead())
>     {
>         if (debug >= 3)
>         {
>             log("    Caching from '" + file.getAbsolutePath() +
>                 "' modified '" +
>                 (new java.sql.Timestamp(file.lastModified())) +
>                 "'");
>         }
>         classCache.put(name, new ClassCacheEntry(clazz, file,
> file.lastModified()));
>     }
> } catch(AccessControlException ace)
>
> Printing out the value of 'pathname' just before this code executes gives
>
> "jndi:/localhost/AddressBook/WEB-INF/classes\com\develop\ewebjava\
> lab\Browse
> .class",
>
> which means that the 'file' doesn't exist and so doesn't get added to the
> cache.
>
> Should that 'jndi:/localhost' be there ?
>
> This is with the latest nightly build BTW,
>
> Kevin Jones
> DevelopMentor
> www.develop.com
>