Have you tried using AbcModule as an override module?:

@Override
protected Injector getInjector()
{
    return Guice.createInjector(Modules.override(new JerseyServletModule()
    {
        @Override
        protected void configureServlets()
        {
            serve("/*").with(GuiceContainer.class, params);
        }
    }).with(new AbcModule()));
}


On Mon, Oct 20, 2014 at 3:22 PM, Aseem <aseem.bels...@gmail.com> wrote:

> Hi,
>
> Receiving "A binding to XXX was already configured at YYY" due to
> using JerseyServletModule and RequestScopeModule from resteasy.
>
> All the classes that RequestScopeModule binds to a provider are already
> being bound in JerseyServletModule while creating the injector. Not
> installing RequestScopeModule is not an option with the current code I'm
> working with since it enables the objects to be referred using @Context
> annotation at runtime (and its a third party).
>
> Code looks like:
>
> @Override
> protected Injector getInjector()
> {
>     return Guice.createInjector(new JerseyServletModule()
>     {
>         @Override
>         protected void configureServlets()
>         {
>             install(new AbcModule());
>
>             //params, filters and other modules
>
>             serve("/*").with(GuiceContainer.class, params);
>         }
>     });
> }
>
> AbcModule.configure:
>
> @Override
> protected void configure()
> {
>     install(new RequestScopeModule());
> }
>
> Client code uses @Context UriInfo uriInfo; which is always null in case I
> do not install RequestScopeModule (since its already bound but not
> available in the Context). And installing it gives conflicts on all of the
> classes for which the providers are being created when inserting into the
> Context of the request.
>
> Is there a way to resolve these conflicts (possibly by removing bindings
> from JerseyServletModule() and letting guice rebind those from
> RequestScopeModule)?
>
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "google-guice" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to google-guice+unsubscr...@googlegroups.com.
> To post to this group, send email to google-guice@googlegroups.com.
> Visit this group at http://groups.google.com/group/google-guice.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-guice/b8b3eb6f-b24e-43ec-8813-c2d8ca55c01f%40googlegroups.com
> <https://groups.google.com/d/msgid/google-guice/b8b3eb6f-b24e-43ec-8813-c2d8ca55c01f%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-guice+unsubscr...@googlegroups.com.
To post to this group, send email to google-guice@googlegroups.com.
Visit this group at http://groups.google.com/group/google-guice.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-guice/CAHNex9_wjPc1h3yOfKfNv3-TLAcpRoFttKhBvXuc2D3jfoRpag%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to