title: Guice configuration error: No implementation was bound
body: <p>I'm trying to make DI with Guice work, doing (as it seems to me) exactly what's in <a href="http://code.google.com/p/google-guice/wiki/BindingAnnotations" rel="noreferrer">the manual</a>.</p>
  
  <p>I can't explain the problem because I don't really understand it - everything seems very logical and should work.. but it doesn't. So, I can only attach the code and the stacktrace:</p>
  
  <pre><code>public class Runner {
  
      public static void main(String[] args) {
          Injector injector = Guice.createInjector(new TestModule());
          //next line throws the exception
          JMeterComponent jMeterComponent = 
               injector.getInstance(JMeterComponent.class);
          ....
      }
  }
  </code></pre>
  
  <p>As you can see, I'm trying to instantiate object of <code>JMeterComponent</code> class. It's constructor (as you'll see later) accepts 3 arguments: all of them should be also instantiated by IoC and injected.</p>
  
  <p>And here's the <code>TestModule</code> with configuration of these 3 arguments:</p>
  
  <pre><code>public class TestModule extends AbstractModule {
  
      @Override
      protected void configure() {
          bind(Callable.class).annotatedWith(Names.named("JMeter"))
                    .to(JMeterTask.class);      
          bind(Processor.class).annotatedWith(Names.named("JMeter"))
                    .to(JMeterResultsProcessor.class);
          bind(Renderer.class).annotatedWith(Names.named("JMeter"))
                    .to(JMeterResultsWikiRenderer.class);
      }
  }
  </code></pre>
  
  <p>Now, let's look at those concrete implementations - <code>JMeterTask</code>, <code>JMeterResultsProcessor</code> and <code>JMeterResultsWikiRenderer</code> (all of them have fake bodies for the simplicity):</p>
  
  <pre><code>public class JMeterTask implements Callable&lt;JMeterRawResults&gt; {
  
      public JMeterRawResults call() throws Exception {
          return new JMeterRawResults();
      }
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>public class JMeterResultsProcessor implements 
                     Processor&lt;JMeterRawResults, JMeterResults&gt; {
  
      public JMeterResults process(JMeterRawResults raw) {
          return new JMeterResults();
      }
  }
  </code></pre>
  
  <p><p></p>
  
  <pre><code>public class JMeterResultsWikiRenderer implements Renderer&lt;JMeterResults&gt; {
  
      public Map&lt;String, String&gt; render(JMeterResults jMeterResults) {
          Map&lt;String, String&gt; results = Maps.newHashMap();
          ...
          return results;
      }
  }
  </code></pre>
  
  <p>And now let's look at the <code>JMeterComponent</code> class, which instance's construction is the aim of the whole DI-related stuff here:</p>
  
  <pre><code>public class JMeterComponent extends AbstractComponent&lt;String, String&gt; {
  
      @Inject
      public JMeterComponent(@Named("JMeter") Callable&lt;String&gt; task, 
                             @Named("JMeter")Processor&lt;String, String&gt; processor, 
                             @Named("JMeter")Renderer&lt;String&gt; renderer) {
          super(task, processor, renderer);
      }
  }
  </code></pre>
  
  <p>And here's the stacktrace:</p>
  
  <pre><code>Exception in thread "main" com.google.inject.ConfigurationException: Guice configuration errors:
  
  1) No implementation for stat.domain.Processor&lt;java.lang.String, java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter) was bound.
    while locating stat.domain.Processor&lt;java.lang.String, java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter)
      for parameter 1 at stat.components.jmeter.JMeterComponent.&lt;init&gt;(JMeterComponent.java:18)
    while locating cstat.components.jmeter.JMeterComponent
  
  2) No implementation for stat.domain.Renderer&lt;java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter) was bound.
    while locating stat.domain.Renderer&lt;java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter)
      for parameter 2 at stat.components.jmeter.JMeterComponent.&lt;init&gt;(JMeterComponent.java:18)
    while locating stat.components.jmeter.JMeterComponent
  
  3) No implementation for java.util.concurrent.Callable&lt;java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter) was bound.
    while locating java.util.concurrent.Callable&lt;java.lang.String&gt; annotated with @com.google.inject.name.Named(value=JMeter)
      for parameter 0 at stat.components.jmeter.JMeterComponent.&lt;init&gt;(JMeterComponent.java:18)
    while locating stat.components.jmeter.JMeterComponent
  </code></pre>
  
  <p>Some additional facts:</p>
  
  <ol>
  <li>I use guice-2.0 (with <code>featured</code>
  label)</li>
  <li>There's no more any annotation from <code>com.google.inject</code> package in any other class in the code</li>
  <li>Interfaces <code>Processor</code> and <code>Renderer</code> are placed in one module, and their <code>jmeter</code>-implementations (<code>JMeterResultsProcessor</code> and other) and <code>JMeterComponent</code> class are placed in another module.</li>
  </ol>
  
  <p>That's pretty much everything there's to say about it.</p>
  
  <p>Sorry for such a long post and thanks for your patience to read it to the end. </p>
  
  <p>Any ideas on why did the errors occur and how to fix it?</p>