ServletContextListener not being invoked

后端 未结 4 1304
孤独总比滥情好
孤独总比滥情好 2020-12-16 12:56

I creating a Java EE 7 project using Eclipse Maven plugin. My problem is when I run the application the class that implements SerlvetContextListener does not get invoked. Wh

4条回答
  •  再見小時候
    2020-12-16 13:14

    For the record, I'm adding yet another possible (and rather vicious) cause of ServletContextListener not being invoked.

    This can happen when you have a java.lang.LinkageError, that is when you forgot to add provided to your javax.servlet-api dependency. In such a case the listener instance is created but only the static part is executed, not the contextInitialized and contextDestroyed methods.

    You shall discover only when you invoke some servlet, as the linkage error is not raised during listener instantiation.

提交回复
热议问题