Bug 49952 - ServletContainerInitializer can't actually add listeners
ServletContainerInitializer can't actually add listeners
Status: RESOLVED FIXED
Product: Tomcat 7
Classification: Unclassified
Component: Catalina
trunk
PC All
: P2 normal (vote)
: ---
Assigned To: Tomcat Developers Mailing List
:
Depends on:
Blocks:
  Show dependency tree
 
Reported: 2010-09-17 13:49 UTC by david jencks
Modified: 2010-10-06 17:47 UTC (History)
0 users



Attachments
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.