Open GoogleCodeExporter opened 9 years ago
See related discussion:
http://groups.google.com/group/warp-core/tree/browse_frm/thread/6aef135cd349f62b
/71572508e4640fce?rnum=11&_done=%2Fgroup%2Fwarp-core%2Fbrowse_frm%2Fthread%2F6ae
f135cd349f62b%3F#doc_b3c92603aeab6453
Original comment by gili.tza...@gmail.com
on 23 Sep 2008 at 1:26
Turns out this is caused by fact that Key.get() was not bound to() anything. If
you
remove in(Scopes.SINGLETON) Guice will notice this and issue an error:
com.google.inject.ConfigurationException: Missing binding to
PermanentRedirect annotated with
@com.google.inject.name.Named(value=RedirectMain).
It seems that Scopes.SINGLETON does not expect or check for this kind of error
so it
dies with a cryptic NPE instead.
Please add this error checking into Scopes.SINGLETON.
Original comment by gili.tza...@gmail.com
on 24 Sep 2008 at 4:36
Better yet, the in() method should require to() to have been invoked
beforehand. This
has the added benefit of fixing the problem across all (future) Scope
implementations.
Original comment by gili.tza...@gmail.com
on 24 Sep 2008 at 5:26
As mentioned above, for an "AbstractModule" subclass this is equivalent to
bind(PermanentRedirect.class)
.annotatedWith(Names.named("RedirectMain"))
.in(Scopes.SINGLETON);
This is not a problem with Scopes.SINGLETON, but rather that the provider
passed into
the scope is a "ProviderToInternalFactoryAdapter" with a null internalFactory.
The same thing without the annotation does work OK:
bind(PermanentRedirect.class)
.in(Scopes.SINGLETON);
So it seems that this is a bug.
As a work-around, you may want something like this:
bind(PermanentRedirect.class)
.annotatedWith(Names.named("RedirectMain"))
.to(PermanentRedirect.class)
.in(Scopes.SINGLETON);
However, that also produces an error. The one work-around I have found that
does work
is as follows:
bind(PermanentRedirect.class)
.annotatedWith(Names.named("RedirectMain"))
.to(new TypeLiteral<PermanentRedirect>() {})
.in(Scopes.SINGLETON);
Original comment by tonyand...@gmail.com
on 2 Oct 2008 at 2:37
I believe this is fixed in current snapshots.
Original comment by limpbizkit
on 30 Dec 2008 at 11:57
Confirmed against r748.
Original comment by gili.tza...@gmail.com
on 31 Dec 2008 at 12:15
Original issue reported on code.google.com by
gili.tza...@gmail.com
on 23 Sep 2008 at 1:24