title: Why is constructor of CDI bean class called more than once
body: <p>I have annotated a class with @ApplicationScoped. With @Inject I get instances of this class injected into several @RequestScopded JAX-RS services:</p>
  
  <pre class="lang-java prettyprint-override"><code>@ApplicationScoped
  public class MySingleton {
    MySingleton() {
      System.out(this + " created.");
    }
  }
  
  @RequestScoped
  public class MyRS {
    @Inject MySingleton mySingleton;
    public void someMethod() {
      // do something with mySingleton
    }
  }
  </code></pre>
  
  <p>Basically this works fine. Howeger, at least when I run this in WebSphere 8.5 the constructor of MySingleton is invoked twice, resulting in output like</p>
  
  <pre><code>my.package.MySingleton_$$_javassist_26@cddebf9b created.
  my.package.MySingleton@e51e26d1 created.
  </code></pre>
  
  <p>I planned to do some expensive initialization in the constructor, which would obviously be executed twice.</p>
  
  <p>I believe that one of the constructor calls is for generating some kind of proxy for the actual "worker" instance. But how can I avoid having my initialization code executed twice? The "solution" to do a lazy initialization in all methods of MySingleton is not very attractive.</p>