Issue Type: Bug Bug
Affects Versions: 2.1.0.Beta2
Assignee: Jozef Hartinger
Components: Servlet Container Support
Created: 26/Sep/13 4:09 AM
Description:

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();
    }
Environment: weld-servlet with Jetty (this bug doesn't affect Wildfly/EE container deployment)
Project: Weld
Priority: Major Major
Reporter: Christian Bauer
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira