During HttpSession reloading HttpSessionActivationListener[s] are notified *before* ServletContextListner[s]. This occurs during Tomcat startup and context reloading. IMHO this is a bug. Objects bound into HttpSession on session activation (e.g. after distributed session migration or reloading) typically expect that ServletContext is already created and properly configured - as in distributed session migration scenario. Spec does not madate anything like that explicitly, however my intuition is so (see SRV.3.7 in Servlet 2.4). I'll attach test-case WAR after submission.
Created attachment 12237 [details] Test case: source files and prepackaged WAR
Exactly my opinion. I also cannnot find anything in the spec 2.3 or 2.4 reg. this. So it's a spec problem not a Tomcat problem. I would also expect that preloaded servlets have run before the sessionDidActivated() method is called.
We've agreed (after also discussing this on the mailing list) that it's a spec problem, so I'm closing it for now. If the spec changes we'll of course reopen this item or create a new one, and make sure the Tomcat implementation obeys the spec.
Yesterday I sent a problem report regarding this to 'jsr-154-comments@jcp.org' Michael