Weld 2.3.5异常:添加org.jboss.weld.construction.relaxed=true后部署报错
org.jboss.weld.construction.relaxed=true Let’s break down what’s going on here and whether this is expected behavior or a bug:
First, the org.jboss.weld.construction.relaxed=true property enables Weld’s relaxed construction mode, which lets CDI beans be created even if their dependencies aren’t fully initialized yet—this is designed to fix circular injection problems. But when you added this setting, your deployment failed with a NullPointerException (NPE) originating from Mojarra’s JavaFlowLoaderHelper.loadFlows() method, which is part of WildFly’s bundled JSF implementation.
Is this expected?
No, this is not expected behavior—this is almost certainly a compatibility bug between Weld’s relaxed construction mode and Mojarra’s JSF flow loading logic, paired with poor error logging that doesn’t connect the NPE to your Weld configuration change. Here’s why:
- Mojarra’s flow loader likely assumes all required CDI beans are fully initialized when it runs during startup. Relaxed construction changes how beans are instantiated, so one of the dependencies the flow loader relies on might be in an incomplete state, triggering the NPE.
- The stack trace only points to JSF internals without mentioning your Weld config change, which makes troubleshooting way harder than it needs to be. This lack of context in the exception is a usability flaw that could be improved, but the core issue is the integration conflict.
How to confirm and address this:
- Test without JSF flows: If your app doesn’t use JSF flows, try removing any flow definitions from your faces config and redeploy with the relaxed construction setting. If it works, you’ve confirmed the problem is specific to JSF flow loading.
- Report the bug: This is an integration issue between WildFly’s Weld and Mojarra components. You should file an issue with the WildFly project, including details of your setup, the exact Weld property you added, and the full stack trace you shared.
- Temporary workaround: If you need relaxed construction for circular dependencies, consider initializing JSF flows manually after the app is fully started, or refactor your CDI beans to avoid needing relaxed construction altogether (if possible).
内容的提问来源于stack exchange,提问作者Ebuzer Taha KANAT

