Bug 49952 - ServletContainerInitializer can't actually add listeners
Summary: ServletContainerInitializer can't actually add listeners
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Catalina (show other bugs)
Version: trunk
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2010-09-17 13:49 UTC by david jencks
Modified: 2010-10-06 17:47 UTC (History)
0 users

Keep the listeners added by ServletContainerInitializer (4.64 KB, patch)
2010-09-17 13:49 UTC, david jencks
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description david jencks 2010-09-17 13:49:20 UTC
Created attachment 26044 [details]
Keep the listeners added by ServletContainerInitializer

Any listeners added by a ServletContainerInitializer will be wiped out when the listeners from web.xml are sorted and overwrite the arrays that already have the SCI-added listeners in them.

I've taken the approach of keeping the single list of listeners from web.xml and keeping the sort into types in listenerStart.  I think it might also be possible and more elegant to have the addApplicationListener method be the same code as the ServletContext.addListener(String listenerClassName) method.

Patch includes a test demonstrating the problem.  The patch to ServletContext may need line number adjustment unless you have applied my patch for supplying the jsp file as a jsp servlet init param.
Comment 1 Mark Thomas 2010-10-06 17:47:25 UTC
Fixed in trunk and will be in 7.0.4 onwards.