Summary: | getContext("/") returns null | ||
---|---|---|---|
Product: | Tomcat 7 | Reporter: | Karl Olson <karl.olson> |
Component: | Catalina | Assignee: | Tomcat Developers Mailing List <dev> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | ivannikolchov |
Priority: | P2 | ||
Version: | 7.0.59 | ||
Target Milestone: | --- | ||
Hardware: | All | ||
OS: | All | ||
Attachments: | test.war |
Description
Karl Olson
2015-02-27 21:27:38 UTC
I believe this was reported recently as a regression due to the fix for bug #57190 and fixed in r1661867 (trunk) r1662178 (Tomcat 8) and r1662179 (Tomcat 7). There was no previous BZ issue for it, so this one is as good as any to document it. Changelog for the Tomcat 7 fix: <fix> Correct a regression in the fix for <bug>57190</bug> that incorrectly required the path passed to <code>ServletContext.getContext(String)</code> to be an exact match to a path to an existing context. (markt) </fix> This fix will be included in Tomcat 7.0.60 and later. *** Bug 57733 has been marked as a duplicate of this bug. *** *** Bug 57733 has been marked as a duplicate of this bug. *** *** Bug 57733 has been marked as a duplicate of this bug. *** (In reply to Christopher Schultz from comment #1) > I believe this was reported recently as a regression due to the fix for bug > #57190 and fixed in r1661867 (trunk) r1662178 (Tomcat 8) and r1662179 > (Tomcat 7). > > There was no previous BZ issue for it, so this one is as good as any to > document it. > For a reference, discussion about ServletContext.getContext() API on dev@ list of that time, Thread "Two serious issues have been introduced in Tomcat 7 and Tomcat 8..." started 2015-02-23, http://markmail.org/thread/wwfgnc6qwgaenwol It looks like this bug was re-introduced on the Tomcat 7 branch in 7.0.61 (In reply to Paul Taylor from comment #6) Quick test: It does work in 7.0.78. Note that the ServletContext.getContext() method is disabled by default for security reasons. It must be explicitly enabled by setting crossContext="true" in Context configuration of the calling web application. Created attachment 35180 [details] test.war Sample web application that demonstrates that the feature is working successfully. Steps: 1. Deploy it as webapps/test.war 2. Start Tomcat 3. Access http://localhost:8080/test/ It prints: getContext("/"): org.apache.catalina.core.ApplicationContextFacade@16b6c55 Tested with 7.0.78. |