Can you replicate this with extremely minimalist ExternalDataSourceModule() and
PushServletModule()s? The devil's in the details here. What is being bound
may have an impact.
One thing worth noting is that, as I recall, when you createChildInjector() you
force bindings sooner than they would be in a normal binding context - I
believe this is to resolve things in the parent so they can be available to the
chile. However, this can move the problem that would be exposed later in the
single-injector case to injector-creation time, which may be why these look
different. If you could empty out these modules until you have versions that
both invoke this problem and you can post, that would help, since then we can
see what's actually going wrong in the bindings.
Christian.
On Mar 13, 2012, at 1:04 AM, Warren wrote:
> 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.
>
--
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.