-
1. Re: Bean available before post construct called
csa Oct 15, 2013 10:50 AM (in response to jannis)Hi Jannis,
That doesn't sound good. We have an integration test that verifies @PostConstruct ordering that passes reliably. However, it's not using @Producers and no multi-project setup. The latter seems less likely to cause problems though.
Can you file a JIRA for this? If you have a testcase (i.e. similar to this: https://github.com/errai/errai/blob/master/errai-cdi/weld-integration/src/test/java/org/jboss/errai/cdi/injection/client/test/PostConstructOrderTest.java) to reproduce the problem or even a potential fix, please feel free to send us a pull request.
Thanks,
Christian
-
2. Re: Bean available before post construct called
jannis Oct 17, 2013 2:55 PM (in response to csa)Hello Christian,
thanks for the answer. I created the JIRA: [ERRAI-659] Bean available before post construct called - JBoss Issue Tracker
I also tried to reproduce the issue with a test, but was not successful. If I will be able to reproduce it, I will let you know.
Cheers
Jannis
-
3. Re: Re: Bean available before post construct called
jannis Oct 18, 2013 9:58 AM (in response to jannis)Hello Christian,
I think I found the source of the problem:
- A proxy is generated for Nesting in BootstrapperImpl.
- During AsyncCreationalContext.resolveAllProxies, the post construct methods of all proxied beans are executed.
- In AsyncCreationalContext.finish, resolveAllresolveAllProxies is executed before fireAllInitCallbacks (the same is true for SimpleCreationalContext.finish).
- Nesting.postConstruct is executed during resolveAllProxies.
- Nested.postConstruct is executed during fireAllInitCallbacks.
--> Nesting.postConstruct is executed before Nested.postConstruct.
I am not sure, whether this is the actual problem. Maybe, there should be no proxy for Nesting in the first place.
Cheers
Jannis
-
4. Re: Bean available before post construct called
csa Oct 18, 2013 1:26 PM (in response to jannis)Interesting. Thanks for digging this far, Jannis.
Just to make sure. Do you experience this problem with both the async (which you seem to be using) and sync bean manager?
Cheers,
Christian
-
5. Re: Bean available before post construct called
jannis Oct 18, 2013 1:38 PM (in response to csa)Oh, sorry for the confusion. No, I did not experience this problem with the sync bean manager. I only used the async one. I assumed a similar behavior based on the source code of the mentioned methods, but I did not verify it.
Edit: What I also forgot to mention: I am facing the issues during the initialization of the bean manager (starting with Container.onModuleLoad).