Bug 57446 - Catalina presents a wrapped ServletContext in de-init phase to application listeners
Summary: Catalina presents a wrapped ServletContext in de-init phase to application li...
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.0.9
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-01-15 12:11 UTC by Birger Zimmermann
Modified: 2015-01-19 11:12 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
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.