|Summary:||Catalina presents a wrapped ServletContext in de-init phase to application listeners|
|Product:||Tomcat 8||Reporter:||Birger Zimmermann <bzi>|
|Component:||Catalina||Assignee:||Tomcat Developers Mailing List <dev>|
Description Birger Zimmermann 2015-01-15 12:11:30 UTC
JSF Applications (Mojarra 2.2.x) fail to shutdown properly, because Catalina presents a wrapped ServletContext (NoPluggabilityServletContext) in de-init phase (e.g. stop webapp cmd issued via jmx). The problem here is that the wrapped ServletContext (NoPluggabilityServletContext) does not appear to be "equal" (equals, etc. methods not delegated) as the one in the init phase (start). I filed a bug on the mojarra JIRA: https://java.net/jira/browse/JAVASERVERFACES-3687 but it was not accepted, because they argue this is a container issue. Maybe a workaround could fix it for context "comparing" webapps. In this case the mojarra implementation uses a List (CopyOnWriteArrayList) to match (contains) if the ServletContext has been initialized. So a delegation of the "equals" method in the NoPluggabilityServletContext class could do the fix, but might cause other sideeffects in the container, which i didn't lookout. A more detailed approach would be to get a light on the specification - what doues it say about the ServletContext instance and presented proxies in the application lifecycle.
Comment 1 Mark Thomas 2015-01-17 17:53:40 UTC
Seeing the same ServletConext for contextInitialized() and contextDestroyed() seems like a reasonable expectation to me. I'd agree that this is something that the Tomcat folks need to take a look at. It is on my list for the coming week.
Comment 2 Mark Thomas 2015-01-19 09:28:21 UTC
This has been fixed in trunk, 8.0.x (for 8.0.18 onwards) and 7.0.x (for 7.0.58 onwards).
Comment 3 Birger Zimmermann 2015-01-19 10:53:01 UTC
Just checked the issue with the latest trunk. Seems like it is still not fixed. Now the org.apache.catalina.core.StandardContext$NoPluggabilityServletContext is presented in the init phase. And a org.apache.catalina.core.ApplicationContextFacade in the de-init. How i understand the issue; it is a must to present the same context instance in init and de-init phase?
Comment 4 Mark Thomas 2015-01-19 11:12:11 UTC
Check again. This has been fixed and includes a test case to confirm the correct behaviour. Please do not reopen this issue unless you can provide a patch to the existing test case that demonstrates a problem.