CDI can throw NullPointerException if application startup fails #26054
Labels
in:CDI
in:Web Components
release bug
This bug is present in a released version of Open Liberty
release:230010
Projects
Describe the bug
When an error occurs during application startup which causes startup to fail, CDI can sometimes throw a
NullPointerException
which appears in the logs.This doesn't cause any harm to a working system since it only occurs when app startup fails, but it causes confusion because it looks like the NPE is the cause of the app startup failure, rather than being caused by it.
Log messages like the following are seen:
Steps to Reproduce
ServletContainerInitializer
which throws anError
from itsonStartup
method.servlet
andcdi
featuresExpected behavior
The app should fail to start but a NullPointerException from CDI should not be logged.
Diagnostic information:
cdi-4.0
and likely previous CDI features$WLP_OUTPUT_DIR/messages.log
Additional context
Add any other context about the problem here.
Debugging through, it looks like when application startup fails in this way,
contextInitialized
is not called for any registeredServletContextListener
s, butcontextDestroyed
is called.The NPE is a consequence of the
WeldInitialListener
accessing a field incontextDestroyed
which would have been initialized bycontextInitialized
.Although I've reproduced the problem by throwing an
Error
from aServletContainerInitializer
, this error will occur wheneverServletContextListener.contextDestroyed
is called withoutcontextInitialized
being called first.The text was updated successfully, but these errors were encountered: