Take the 2-minute tour ×

According to the ThrowingProvider documentation of Guice I have the following interface:

public interface IConfigurableProvider<T> extends ThrowingProvider<T, ConfigException> {}

I have multiple classes that implements this interface, let assume I have the following:

public class SomethingProvider extends ConfiguredProvider implements IConfigurableProvider<Something> {}

Of course this class implements the necessary method:

public Something get() throws ConfigException { /* ... */ }

In my module, I have the following code in MyModule.java

    .bind(IConfigurableProvider.class, Something.class)

But when I start my application the following error produced:

6) No implementation for com.package.Something was bound.
  while locating com.package.Something
    for parameter 5 at com.package.OtherClass.<init>(OtherClass.java:78)
  at com.package.MyModule.configure(MyModule.java:106)

I don't really know where should I start looking for the bug.

Update: It provides the same error even if I set the scope as well:

    .bind(IConfigurableProvider.class, Something.class)
share|improve this question
As the accepted answer pointed out I misunderstood the usage of ThrowingProviderBinder. The injected constructor should wait for a provider instead of the provided object (and there should be the checked exception handled). –  KARASZI István Jan 13 '11 at 10:34
add comment

1 Answer

up vote 3 down vote accepted

Rather than injecting the Something, you need to inject the IConfigurableProvider<Something>:

public class OtherClass {
  public OtherClass(IConfigurableProvider<Something> somethingProvider) {
share|improve this answer
but I don't want to modify the constructors. is there any way to achieve what I really want? –  KARASZI István Jan 13 '11 at 8:13
I think I'll forget the ThrowingProvider and simply use the Provider interface and wrap the source exception into ProvisionException –  KARASZI István Jan 13 '11 at 8:31
add comment

Your Answer


