I have implemented GuiceServletContextListener like this:
@Override
protected Injector getInjector()
{
Injector parentInjector = Guice.createInjector(new AbstractModule()
{
@Override
protected void configure()
{
// for troubleshooting this issue I have left
this blank, normally other
// bindings would be bound here that
ExternalDataSourcesModule depends on
}
});
Injector childInjector = parentInjector.createChildInjector(new
ExternalDataSourcesModule(), new PushServletModule());
return childInjector;
}
I get the following exception message:
SEVERE: Exception starting filter GuiceFilter
com.google.inject.ConfigurationException: Guice configuration errors:
1) Unable to create binding for java.util.Map<java.lang.String,
c.w.p.s.ItemService>. It was already configured on one or more child
injectors or private modules
bound at
c.w.p.s.ExternalDataSourcesModule.configure(ExternalDataSourcesModule.java:
53)
If it was in a PrivateModule, did you forget to expose the binding?
while locating java.util.Map<java.lang.String, c.w.p.s.ItemService>
for field at c.w.p.s.ItemResource.itemServices(ItemResource.java:
23)
while locating c.w.p.s.ItemResource
When I Implement getInjector() like this, I get no errors and
everything works.
@Override
protected Injector getInjector()
{
return Guice.createInjector(new ExternalDataSourcesModule(), new
MyServletModule());
}
No other code has changed other than the getInjector() method.
ExternalDataSourcesModule and MyServletModule are identical in both
implementations of getInjector(). And in the child injector scenario,
the parent injector has not bound anything.
Why do I get the Guice configuration errors when I configure using a
child injector and I don't when I configure with only the main
injector?
Thanks,
Warren Bell
--
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.