title: "Please wait until after injection has completed to use this object" error from Guice
body: <p>We have two singleton objects (declared via <code>in(Scopes.SINGLETON)</code>) in Guice that each uses the other in its constructor. Guice's way to implement this is with proxies - it initializes the object at first with a proxy to the other object, and only when that object is needed it is resolved.</p>
  
  <p>When running this code from several threads, we get the following exception:</p>
  
  <pre><code>java.lang.IllegalStateException: This is a proxy used to support
  circular references involving constructors. The object we're proxying is not
  constructed yet. Please wait until after injection has completed to use this
  object.
      at
  com.google.inject.internal.ConstructionContext$DelegatingInvocationHandler.invoke(ConstructionContext.java:100)
  </code></pre>
  
  <p>I assume this is a bug in Guice, because we aren't doing anything out of the ordinary. One workaround we found is initializing the singletons early using <code>.asEagerSingleton()</code>, but this is not very convenient, for testing for example.</p>
  
  <p><s>Is this a known issue?</s> Reported an <a href="http://code.google.com/p/google-guice/issues/detail?id=550" rel="nofollow">issue with Google Guice</a>, reproduces with a standalone test.</p>
  
  <p>Any other suggestions/workaround?</p>