In your case - additional listeners - there is a simple solution. If your application is Servlet 3.0 or higher, you can register listeners B with the annotation:
@WebListener public class BListener implements ServletContextListener { public void contextInitialized(ServletContextEvent sce) { System.out.println("Started BListener"); }
If exposure B is more complex than an extra listener, you can consider a web fragment (requires Servlet 3.0)
source share