5 Replies Latest reply on Oct 18, 2013 1:38 PM by jannis

    Bean available before post construct called

    jannis

      Hello,

       

      we are facing an issue, with the correct execution order of post constructions. The post construction of a nesting bean is executed before the post construction of the nested bean. During the post construction of the nesting bean, methods of the nested bean are called, although the nested bean is not yet ready to be used.

       

      public class Nesting {
           @Inject
           Nested nested;
      
           @PostConstruct
           public void postConstruct() {
                // Called too early
                nested.doSomething;
           }
      }
      
      public class Nested {
           @PostConstruct
           public void ponstConstruct() {
                // Called too late
           }
      
           public void doSomething() {
                // Called before post construct
           }
      }
      

       

       

      This behavior does not always occur. Whether it occurs can change from build to build and seems to be not deterministic. Except, that we encountered it only in development mode so far (also when recompiling with super dev mode).

       

      Possible sources of the problem, that came into our mind, are the usage of producers and a multi-project set up.

       

      Are there any known issues related to this problem?

       

      Thanks in advance

      Jannis