[ 
https://issues.apache.org/jira/browse/KARAF-7773?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17777255#comment-17777255
 ] 

Grzegorz Grzybek commented on KARAF-7773:
-----------------------------------------

FIrst observation:
{noformat}
2023-10-19T15:12:01,085 | DEBUG | paxweb-config-1-thread-1 (deploy /) | 
HttpServiceEnabled               | 450 - org.ops4j.pax.web.pax-web-runtime - 
8.0.15 | Passing registration of 
EventListenerModel{id=EventListenerModel-20,listener='org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer$ContextDestroyListener@3e747eea',contexts=[{WAB,OCM-11,/,/}]}
 to configuration thread
2023-10-19T15:12:01,085 | DEBUG | paxweb-config-1-thread-1 (deploy /) | 
WebElementEventDispatcher        | 450 - org.ops4j.pax.web.pax-web-runtime - 
8.0.15 | Sending web element event DEPLOYING 
(org.eclipse.jetty.websocket.javax.websocket.server/9.4.48.v20220622): 
org.ops4j.pax.web.service.spi.model.events.EventListenerEventData@e82a33e for 
bundle org.eclipse.jetty.websocket.javax.websocket.server
...
2023-10-19T15:12:01,118 | INFO  | paxweb-config-1-thread-1 (deploy /) | /       
                         | 398 - org.eclipse.jetty.util - 9.4.50.v20221201 | 
org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok)
{noformat}

you see - Pax Web detected 
{{org.eclipse.jetty.websocket.jsr356.server.deploy.WebSocketServerContainerInitializer$ContextDestroyListener}}
 from {{org.eclipse.jetty.websocket.javax.websocket.server/9.4.48.v20220622}} 
while Pax Web 8.0.15 uses Jetty {{9.4.50.v20221201}} - do you have two Jetty 
versions installed?

> WAB ServletContextListener.contextInitialized invoked multiple times during 
> re-deploy (and with wrong context)
> --------------------------------------------------------------------------------------------------------------
>
>                 Key: KARAF-7773
>                 URL: https://issues.apache.org/jira/browse/KARAF-7773
>             Project: Karaf
>          Issue Type: Bug
>          Components: karaf
>    Affects Versions: 4.4.3
>            Reporter: Amichai Rothman
>            Assignee: Grzegorz Grzybek
>            Priority: Major
>         Attachments: paxweb.log, paxweb.trace.log
>
>
> When touching a WAB bundle with a context listener as described belower, the 
> undeploy/deploy cycle, instead of just invoking destroy on the old context 
> and initialize on the new one, seems to destroy the old one, re-initialize 
> the old one (with the wrong "whiteboard extender" context), destroy it again, 
> initialize the new one (with correct context), and initialize the old one 
> once more (but without the filter init).
> I'll describe my full scenario, even though it's possible the issue can be 
> reproduced with a simpler setup:
> I have an application consisting of multiple bundles in the karaf deploy 
> folder. One of them is a WAB. It's web.xml only contains display-name and 
> listener-class with a ServletContextListener. The listener contextInitialized 
> implementation instantiates a custom Filter, whose class is imported from a 
> different app bundle:
> {code:java}
> Filter filter = new MyFilter();
> context.addFilter("MyFilter", filter)
>     .addMappingForUrlPatterns(EnumSet.of(DispatcherType.REQUEST, 
> DispatcherType.FORWARD), true, "/*");
> {code}
> The filter's init method is invoked successfully and all is good.
> Then, I update/touch the WAB bundle in the deploy folder.
> This causes a thread named "paxweb-config-3-thread-1 (undeploy /)" to call 
> the listener's  contextDestroyed method as expected, but then it also 
> immediately calls the contextInitialized method again (still from the 
> undeploy thread, and still the same old listener instance), this time with 
> the servlet context of the pax-web-extender-whiteboard rather than the WAB 
> bundle. It creates another filter instance, whose init method gets invoked 
> with the pax-web-extender-whiteboard context as well (my init implementation 
> throws an exception at this point when the context is wrong, resources aren't 
> found etc.).
> Then a thread named "paxweb-config-3-thread-1 (deploy /)" (notice undeploy 
> changed to deploy) calls contextDestroyed, still with the extender context. 
> Finally, a new listener instance is craeted, contextInitialized is invoked 
> again, this time with the correct WAB context, followed by the filter's init 
> method. In addition, the old listener instance (which should be dead by now) 
> contextInitialized also gets invoked again, but not followed by the filter 
> init (maybe because it previously threw an exception on it? just guessing).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to