[MAGNOLIA-7107] Improve error handling/logging in info.magnolia.objectfactory.guice.GuiceComponentProviderBuilder#build method Created: 14/Aug/17 Updated: 16/Mar/21 |
|
| Status: | Accepted |
| Project: | Magnolia |
| Component/s: | None |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major |
| Reporter: | Milan Divilek | Assignee: | Unassigned |
| Resolution: | Unresolved | Votes: | 1 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Template: |
|
| Acceptance criteria: |
Empty
|
| Task DoD: |
[ ]*
Doc/release notes changes? Comment present?
[ ]*
Downstream builds green?
[ ]*
Solution information and context easily available?
[ ]*
Tests
[ ]*
FixVersion filled and not yet released
[ ] 
Architecture Decision Record (ADR)
|
| Story Points: | 1 |
| Description |
|
Guice.createInjector(resolveStageToUse(), module) can fail on several different exceptions (for example com.google.common.util.concurrent.ExecutionError: java.lang.NoClassDefFoundError: info/magnolia/cms/servlets/CommandBasedMVCServletHandler), but we are handling/log only when com.google.inject.CreationException occurs. try { Injector injector = Guice.createInjector(resolveStageToUse(), module); injector.injectMembers(componentProvider); return componentProvider; } catch (CreationException e) { log.error("Magnolia failed to load module configuration with types {} and components {}. Please ensure you don't have any legacy modules present in your web application.", configuration.getAnnotatedTypeMappings(), configuration.getAnnotatedComponents(), e); throw e; } Problem is when the error occurs for example during startup because Magnolia then tries to do MgnlContext.release(), but this fails on NPE because injector is not set in ComponentProvider. You will then get only stacktrace of NPE and is hard to figure out what is cause of issue. We had problem with this on corporate website, also https://forum.magnolia-cms.com/forum/thread.html?threadId=215d4e7f-21b4-483c-ba5d-c81dc1331315 and SUPPORT-7807... |