why there is two instances of a singleton with Google Guice dependency injection framework

guice, java, singleton

Solution

The problem here was the binding declaration.

We fixed it by replacing the binding declaration to:

bind(FooImpl.class).in(Scopes.SINGLETON);
bind(Foo.class).to(FooImpl.class); 

Problem

There’s 2 Singleton instances, both created by Google Guice, in my application. How’s that even possible? The binding is done as follow: ``` bind(Foo.class).to(FooImpl.class).in(Scopes.SINGLETON); ```

Original source