-
Bug
-
Resolution: Done
-
Major
-
2.1.0.Beta2
-
None
-
weld-servlet with Jetty (this bug doesn't affect Wildfly/EE container deployment)
public class ObserverTest { final private static Logger log = Logger.getLogger(ObserverTest.class.getName()); public void start(@Observes @Initialized(ApplicationScoped.class) Object o) throws Exception { log.info("### START"); } public void stop(@Observes @Destroyed(ApplicationScoped.class) Object o) throws Exception { log.info("### STOP"); } }
The @Destroyed(ApplicationScoped.class) event is never fired. Most likely this code in org.jboss.weld.environment.servlet.Listener is wrong:
@Override
public void contextDestroyed(ServletContextEvent sce) {
/* Wrong order:
bootstrap.shutdown();
if (container != null) {
container.destroy(new ContainerContext(sce, null));
}
super.contextDestroyed(sce);
*/
// Workaround:
if (container != null) {
container.destroy(new ContainerContext(sce, null));
}
super.contextDestroyed(sce);
bootstrap.shutdown();
}