You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Ian Boston <ie...@tfd.co.uk> on 2009/09/25 11:55:32 UTC
Reloading servlets
Has anyone noticed problems reloading a servlet bundle ?
After a reload of a bundle containing a servlet I find that the
original servlet is still used, verified by logging "this".
I know the old servlet was unloaded by OSGi since its references
become null after the reload. It looks like the servlet is not being
removed from the ServletResolver.
I will have a deeper look but thought I should ask if anyone else is
seeing the same or if its just me.
Using a reasonably recent Snapshot
Ian
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 11:03, Vidar Ramdal wrote:
> On Fri, Sep 25, 2009 at 11:55 AM, Ian Boston <ie...@tfd.co.uk> wrote:
>> Has anyone noticed problems reloading a servlet bundle ?
>>
>> After a reload of a bundle containing a servlet I find that the
>> original
>> servlet is still used, verified by logging "this".
>
> Using JCRInstall, by any chance?
> https://issues.apache.org/jira/browse/SLING-1106
>
no,
I saw that one and thought it might be something related, but at the
moment my servlet and bundle environment is quite simple.
I will try with the default launchpad to see if the same happens
there. Just in case it something with my local bundles.
Ian
>
> --
> Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
> Sommerrogata 13-15, N-0255 Oslo, Norway
> + 47 22 00 84 00 / +47 21 531941, ext 2070
Re: Reloading servlets
Posted by Vidar Ramdal <vi...@idium.no>.
On Fri, Sep 25, 2009 at 11:55 AM, Ian Boston <ie...@tfd.co.uk> wrote:
> Has anyone noticed problems reloading a servlet bundle ?
>
> After a reload of a bundle containing a servlet I find that the original
> servlet is still used, verified by logging "this".
Using JCRInstall, by any chance?
https://issues.apache.org/jira/browse/SLING-1106
--
Vidar S. Ramdal <vi...@idium.no> - http://www.idium.no
Sommerrogata 13-15, N-0255 Oslo, Norway
+ 47 22 00 84 00 / +47 21 531941, ext 2070
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 12:49, Ian Boston wrote:
>> Yes, everything is possible :)
>>
>> Maybe - for whatever reason - the sling servlet resolver is not
>> registered as an event handler anymore (therefore it should be
>> registered as EventHandler and have the property event.topics).
>>
>> Or the event is not fired from the JcrResourceResolverFactoryImpl
>> (bindResourceProdiver method)
>
>
> or.. because of local modification I am running an out of date
> JcrResourceResolverFactoryImpl .... oops .... wipes egg off
> face.....that will teach me to make mods to implementation code :)
Having fixed this problem in my code base, I re-factored my
modifications to minimize the patch to the sling code base, resulting
in some extension points to JcrResourceResolver2. This represents no
change in functionality in Sling but does allow those extending to do
it in a sensible way. See [1], WDYT? Ok for inclusion ?
Ian
1 https://issues.apache.org/jira/browse/SLING-1129
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 12:41, Carsten Ziegeler wrote:
> Ian Boston wrote
>>
>> but I never see the handleEvent method invoked to reset the cache, I
>> guess that I have done something to the event registration process
>> surrounding the SlingServletResolver, but doing event registrations
>> (or
>> breaking the event flow) somewhere else ? Is that possible ?
>>
> Yes, everything is possible :)
>
> Maybe - for whatever reason - the sling servlet resolver is not
> registered as an event handler anymore (therefore it should be
> registered as EventHandler and have the property event.topics).
>
> Or the event is not fired from the JcrResourceResolverFactoryImpl
> (bindResourceProdiver method)
or.. because of local modification I am running an out of date
JcrResourceResolverFactoryImpl .... oops .... wipes egg off
face.....that will teach me to make mods to implementation code :)
Thanks for your help.
Thanks
>
> Carsten
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
Re: Reloading servlets
Posted by Carsten Ziegeler <cz...@apache.org>.
Ian Boston wrote
>
> but I never see the handleEvent method invoked to reset the cache, I
> guess that I have done something to the event registration process
> surrounding the SlingServletResolver, but doing event registrations (or
> breaking the event flow) somewhere else ? Is that possible ?
>
Yes, everything is possible :)
Maybe - for whatever reason - the sling servlet resolver is not
registered as an event handler anymore (therefore it should be
registered as EventHandler and have the property event.topics).
Or the event is not fired from the JcrResourceResolverFactoryImpl
(bindResourceProdiver method)
Carsten
--
Carsten Ziegeler
cziegeler@apache.org
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 11:51, Ian Boston wrote:
>
> On 25 Sep 2009, at 11:32, Ian Boston wrote:
>
>>
>> On 25 Sep 2009, at 11:09, Carsten Ziegeler wrote:
>>
>>> Ian Boston wrote:
>>>> Has anyone noticed problems reloading a servlet bundle ?
>>>>
>>>> After a reload of a bundle containing a servlet I find that the
>>>> original
>>>> servlet is still used, verified by logging "this".
>>>>
>>>> I know the old servlet was unloaded by OSGi since its references
>>>> become
>>>> null after the reload. It looks like the servlet is not being
>>>> removed
>>>> from the ServletResolver.
>>>> I will have a deeper look but thought I should ask if anyone else
>>>> is
>>>> seeing the same or if its just me.
>>>>
>>>> Using a reasonably recent Snapshot
>>>>
>>> I could imaginge a bug in one of the two:
>>> - the servlet resolver caches the servlet. There should be OSGi
>>> events
>>> when the bundle is updated and this should clear the cache.
>>>
>>> - the new dynamic class loader is still wired to the old bundle. The
>>> class loader listens for bundle events and then throws away the
>>> underlying class loader and creates new ones.
>>>
>>> So maybe one of those two mechanisms is not working properly.
>>> If you could provide a test case I could help searching.
>>
>>
>> I think this must be something I have done, at r815843 unmodified
>> Sling, at least, if I do a simple servlet bound to the HttpSevice
>> and connected either to a static path or a resource type, I cant
>> reproduce the behavior.
>>
>> I will have to see if I can reproduce in my modified environment
>> with the simple servlet.
>
> yes, simple servlet fails to reload in my environment :(, must have
> done something bad to prevent the servlet resolver replacing the
> reference.
>
> Not a Sling problem then.
Using an attached debugger.
In my instance the cache in SlingServletResolver is not cleared by a
reload,
I see re-registration events for bindServlet and unbindServlet
happening with new service references and service objects all of this
works
but I never see the handleEvent method invoked to reset the cache, I
guess that I have done something to the event registration process
surrounding the SlingServletResolver, but doing event registrations
(or breaking the event flow) somewhere else ? Is that possible ?
Ian
> Ian
>
>
>
>>
>> Ian
>>
>>
>>>
>>> Carsten
>>>
>>> --
>>> Carsten Ziegeler
>>> cziegeler@apache.org
>>
>
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 11:32, Ian Boston wrote:
>
> On 25 Sep 2009, at 11:09, Carsten Ziegeler wrote:
>
>> Ian Boston wrote:
>>> Has anyone noticed problems reloading a servlet bundle ?
>>>
>>> After a reload of a bundle containing a servlet I find that the
>>> original
>>> servlet is still used, verified by logging "this".
>>>
>>> I know the old servlet was unloaded by OSGi since its references
>>> become
>>> null after the reload. It looks like the servlet is not being
>>> removed
>>> from the ServletResolver.
>>> I will have a deeper look but thought I should ask if anyone else is
>>> seeing the same or if its just me.
>>>
>>> Using a reasonably recent Snapshot
>>>
>> I could imaginge a bug in one of the two:
>> - the servlet resolver caches the servlet. There should be OSGi
>> events
>> when the bundle is updated and this should clear the cache.
>>
>> - the new dynamic class loader is still wired to the old bundle. The
>> class loader listens for bundle events and then throws away the
>> underlying class loader and creates new ones.
>>
>> So maybe one of those two mechanisms is not working properly.
>> If you could provide a test case I could help searching.
>
>
> I think this must be something I have done, at r815843 unmodified
> Sling, at least, if I do a simple servlet bound to the HttpSevice
> and connected either to a static path or a resource type, I cant
> reproduce the behavior.
>
> I will have to see if I can reproduce in my modified environment
> with the simple servlet.
yes, simple servlet fails to reload in my environment :(, must have
done something bad to prevent the servlet resolver replacing the
reference.
Not a Sling problem then.
Ian
>
> Ian
>
>
>>
>> Carsten
>>
>> --
>> Carsten Ziegeler
>> cziegeler@apache.org
>
Re: Reloading servlets
Posted by Ian Boston <ie...@tfd.co.uk>.
On 25 Sep 2009, at 11:09, Carsten Ziegeler wrote:
> Ian Boston wrote:
>> Has anyone noticed problems reloading a servlet bundle ?
>>
>> After a reload of a bundle containing a servlet I find that the
>> original
>> servlet is still used, verified by logging "this".
>>
>> I know the old servlet was unloaded by OSGi since its references
>> become
>> null after the reload. It looks like the servlet is not being removed
>> from the ServletResolver.
>> I will have a deeper look but thought I should ask if anyone else is
>> seeing the same or if its just me.
>>
>> Using a reasonably recent Snapshot
>>
> I could imaginge a bug in one of the two:
> - the servlet resolver caches the servlet. There should be OSGi events
> when the bundle is updated and this should clear the cache.
>
> - the new dynamic class loader is still wired to the old bundle. The
> class loader listens for bundle events and then throws away the
> underlying class loader and creates new ones.
>
> So maybe one of those two mechanisms is not working properly.
> If you could provide a test case I could help searching.
I think this must be something I have done, at r815843 unmodified
Sling, at least, if I do a simple servlet bound to the HttpSevice and
connected either to a static path or a resource type, I cant reproduce
the behavior.
I will have to see if I can reproduce in my modified environment with
the simple servlet.
Ian
>
> Carsten
>
> --
> Carsten Ziegeler
> cziegeler@apache.org
Re: Reloading servlets
Posted by Carsten Ziegeler <cz...@apache.org>.
Ian Boston wrote:
> Has anyone noticed problems reloading a servlet bundle ?
>
> After a reload of a bundle containing a servlet I find that the original
> servlet is still used, verified by logging "this".
>
> I know the old servlet was unloaded by OSGi since its references become
> null after the reload. It looks like the servlet is not being removed
> from the ServletResolver.
> I will have a deeper look but thought I should ask if anyone else is
> seeing the same or if its just me.
>
> Using a reasonably recent Snapshot
>
I could imaginge a bug in one of the two:
- the servlet resolver caches the servlet. There should be OSGi events
when the bundle is updated and this should clear the cache.
- the new dynamic class loader is still wired to the old bundle. The
class loader listens for bundle events and then throws away the
underlying class loader and creates new ones.
So maybe one of those two mechanisms is not working properly.
If you could provide a test case I could help searching.
Carsten
--
Carsten Ziegeler
cziegeler@apache.org