Hi All,

I'm using Weld in Open Liberty and seeing a NullPointerException from WeldInitialListener when an app fails to start.  The scenario goes something like this:
1) Server and app starts to start.
2) An error occurs in my app code throwing an uncaught exception.
3) Liberty's web container code then attempts to stop the still-not-yet-started app - this calls the WeldInitialListener's contextDestroyed method without ever calling the contextCreated method.
4) Because contextCreated was never called, there is a NullPointerException thrown from contextDestroyed (the lifecycle field is null), which ends up masking the root cause of the problem.

I am in the process of fixing part of the problem (not logging the original exception) in Open Liberty issue 13124[1], but I wonder if we should also check if lifecycle is null in the contextDestroyed method[2] to avoid the NPE.

Thanks,

Andy

[1] https://github.com/OpenLiberty/open-liberty/issues/13124
[2] https://github.com/weld/core/blob/2fe5d1f64c03b89cc562a14cda317098225590c7/modules/web/src/main/java/org/jboss/weld/module/web/servlet/WeldInitialListener.java#L113