Sorry about the late response, but for completeness....

On Tue, Jun 2, 2009 at 3:05 AM, Jason Larsen <[email protected]> wrote:

>
> Hey guys.  I have been converting a non-DI web-app to using Guice, and
> have noticed the warning:
>
> "Multiple injectors detected. Please install only one ServletModule in
> your web application. While you may have more than one injector, you
> should only configure guice-servlet in one of them. (Hint: look for
> legacy ServetModules or multiple calls to Servlets.configure())"
>
>
This should only ever happen if  more than one injector is bootstrapped.


> Digging into the source a little bit, it appears as if this was caused
> by us using Modules.combine() and Modules.override() to compose our
> modules, instead of simply listing our ServletModules in the
> Guice.createInjector() call.  Besides that, we are using the
> recommended pattern of a single GuiceServletContextListener, with one
> Guice.createInjector() call.
>

Hmm, I think this is coz Modules.combine() or override() is creating a child
injector. You should not install servlet modules in a child injector. That
behavior is undefined.


>
> My questions are:
>
> - Should we really listen to the warning and only have one
> ServletModule?  Or should we be trying to keep our modules small and
> simple?
>

You don't need to have just one. You can simply install() many
ServletModules from a parent module.


> - Most importantly, is this really going to cause a problem? Or can we
> safely ignore the warning?
>

Yes it will cause a problem coz the pipelines may be different based on what
exactly happens in your combine()s.


> Thanks for an excellent DI framework.
>

Thanks for the kind words =).

Dhanji.

--

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.


Reply via email to