Did you try the workaround? On Sat, May 15, 2010 at 6:35 PM, yurique <[email protected]> wrote:
> > does the class "this.persister" refers to have any methods > or fields annotated with @Inject? > > Yes, this object is built with guice within another module of an > application and has fields annotated with @Inject. > > > Guice is probably trying to Inject them. > > Thats what it seems to me, too. But I can't find a reason for it to do > so - the object is already built and bound using "toInstance". > > Does this mean, that one cannot bind objects built by Guice (with > different Module and bindings)? This doesn't seem right to me. > > I've just created a simple test project. > > I have the following classes within it: > > ITool - a simple interface > SpecificTool - some implementation of that interface > > IService - another interface > SpecificService - a service that uses an ITool interface (@Inject > private ITool tool) > > Client - a simple class, that uses an IService (@Inject private > IService service) > > > Here's what I do in the test: > * I create one AbstractModule - with bindings for ITest and for > IService > * create an injector using that module and create an instance of > IService (actually an instance of SpecificService) > > Then I create another AbstractModule (and injector) in which I bind > the IService.class to the created object using > bind(...).toInstance(...). This module doesn't "know" about ITool. > Now using this new injector I try to create an instance of Client, > which has an injected IService field. And Guice fails complaining that > ITool is not bound. > > But at this moment Guice has everything needed to successfully build > Client - because IService is already bound to an *existing* instance. > > > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<google-guice%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
