DWR

Attribute "bindPotentiallyConflictingTypes" ignored in DwrGuiceServletModule

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Major Major
  • Resolution: Unresolved
  • Affects Version/s: 3.0.RC1
  • Fix Version/s: 3.0.1
  • Component/s: Guice
  • Documentation Required:
    No
  • Description:
    Hide
    Attribute "bindPotentiallyConflictingTypes" ignored in DwrGuiceServletModule.

    All binds after line 108 don't consider the attribute "bindPotentiallyConflictingTypes". To make it work with Google Guice 2.0 I had to delete all binds after line 108. I think that they don't make sense there, because you already bind them in the beginning of the method.
    Show
    Attribute "bindPotentiallyConflictingTypes" ignored in DwrGuiceServletModule. All binds after line 108 don't consider the attribute "bindPotentiallyConflictingTypes". To make it work with Google Guice 2.0 I had to delete all binds after line 108. I think that they don't make sense there, because you already bind them in the beginning of the method.
  1. patch.txt
    (1 kB)
    Eduardo S. Nunes
    16/Sep/09 9:05 AM

Activity

Hide
David Marginian added a comment - 16/Sep/09 5:47 AM

Tim can you take a look at this?

Show
David Marginian added a comment - 16/Sep/09 5:47 AM Tim can you take a look at this?
Hide
Tim Peierls added a comment - 16/Sep/09 6:21 AM

I was not able to get the DWR-Guice integration module to work with Guice 2.0. I don't think this is the only problem I encountered.

I'm not sure what the issue creator means by "I think that they don't make sense there, because you already bind them in the beginning of the method." There are different bindings in the beginning of the method.

The changes proposed here could break existing code.

Show
Tim Peierls added a comment - 16/Sep/09 6:21 AM I was not able to get the DWR-Guice integration module to work with Guice 2.0. I don't think this is the only problem I encountered. I'm not sure what the issue creator means by "I think that they don't make sense there, because you already bind them in the beginning of the method." There are different bindings in the beginning of the method. The changes proposed here could break existing code.
Hide
Eduardo S. Nunes added a comment - 16/Sep/09 9:05 AM

Sorry about that, I was sleepy and I did a mistake, actually there is no problem with the bindPotentiallyConflictingTypes, the problem is with the DwrGuiceServletModule class, line 112. This line makes dwr incompatible with google-guice 2.0. It generates the following error:

1) A binding to javax.servlet.ServletContext was already configured at org.directwebremoting.guice.DwrGuiceServletModule.configure(DwrGuiceServletModule.java:112).
at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:71)

I don't know exactly the structure of DWR, but I would suggest to add a annotatedWith version and to put this line also inside the IF of line 76. I did this change and now it's everything work perfect. I've also attached a patch, please take a look on it.

Thanks

Show
Eduardo S. Nunes added a comment - 16/Sep/09 9:05 AM Sorry about that, I was sleepy and I did a mistake, actually there is no problem with the bindPotentiallyConflictingTypes, the problem is with the DwrGuiceServletModule class, line 112. This line makes dwr incompatible with google-guice 2.0. It generates the following error: 1) A binding to javax.servlet.ServletContext was already configured at org.directwebremoting.guice.DwrGuiceServletModule.configure(DwrGuiceServletModule.java:112). at com.google.inject.servlet.InternalServletModule.configure(InternalServletModule.java:71) I don't know exactly the structure of DWR, but I would suggest to add a annotatedWith version and to put this line also inside the IF of line 76. I did this change and now it's everything work perfect. I've also attached a patch, please take a look on it. Thanks
Hide
Tim Peierls added a comment - 16/Sep/09 12:35 PM

I think this patch only goes halfway. The point of bindPotentiallyConflictingTypes and related logic is to allow users not to worry about whether they are including the guice-servlet jar in addition to DWR. This patch would break any existing code that was expecting to have ServletContext injected (without an annotation).

How about adding the (un-annotated) ServletContext binding to the if-clause of bindPotentiallyConflictingTypes? I don't have time to make a patch, though.

Show
Tim Peierls added a comment - 16/Sep/09 12:35 PM I think this patch only goes halfway. The point of bindPotentiallyConflictingTypes and related logic is to allow users not to worry about whether they are including the guice-servlet jar in addition to DWR. This patch would break any existing code that was expecting to have ServletContext injected (without an annotation). How about adding the (un-annotated) ServletContext binding to the if-clause of bindPotentiallyConflictingTypes? I don't have time to make a patch, though.
Hide
Tim Peierls added a comment - 16/Sep/09 2:01 PM

Note that bindPotentiallyConflictingTypes, unless overridden by the user, will be false if LocalUtil.classForName("com.google.inject.servlet.ServletModule") returns true. See AbstractDwrModule.java for details.

Show
Tim Peierls added a comment - 16/Sep/09 2:01 PM Note that bindPotentiallyConflictingTypes, unless overridden by the user, will be false if LocalUtil.classForName("com.google.inject.servlet.ServletModule") returns true. See AbstractDwrModule.java for details.
Hide
Eduardo S. Nunes added a comment - 16/Sep/09 2:15 PM

Yes, that's why my patch work and will not break any source code. If the user has guice-servlet in the classpath, DWR will set the context just with the Dwr annotation, otherwiser DWR will set the context with and without annotation, so it will not break existing code.

Show
Eduardo S. Nunes added a comment - 16/Sep/09 2:15 PM Yes, that's why my patch work and will not break any source code. If the user has guice-servlet in the classpath, DWR will set the context just with the Dwr annotation, otherwiser DWR will set the context with and without annotation, so it will not break existing code.
Hide
Tim Peierls added a comment - 16/Sep/09 2:44 PM

Ah, sorry – I didn't read your patch carefully enough. I don't have time to test it, but it looks good to me.

Show
Tim Peierls added a comment - 16/Sep/09 2:44 PM Ah, sorry – I didn't read your patch carefully enough. I don't have time to test it, but it looks good to me.
Hide
Jason Clawson added a comment - 06/Apr/10 11:01 AM

Can we get this fixed and committed? We are having to override the dwr code to get this to work with Guice 2. Its very messy and makes starting new projects based on our tech stack cumbersome.

Show
Jason Clawson added a comment - 06/Apr/10 11:01 AM Can we get this fixed and committed? We are having to override the dwr code to get this to work with Guice 2. Its very messy and makes starting new projects based on our tech stack cumbersome.
Hide
Tim Peierls added a comment - 06/Apr/10 11:18 AM

Has anyone besides Eduardo tried this patch? Six months on, I can't dredge up enough context to evaluate this quickly, but it looks as though back then I thought the patch made sense.

Show
Tim Peierls added a comment - 06/Apr/10 11:18 AM Has anyone besides Eduardo tried this patch? Six months on, I can't dredge up enough context to evaluate this quickly, but it looks as though back then I thought the patch made sense.
Hide
David Marginian added a comment - 18/Apr/10 8:56 AM

No, but if Jason agrees I can put the patch in and he can test it in one of our development builds.

Show
David Marginian added a comment - 18/Apr/10 8:56 AM No, but if Jason agrees I can put the patch in and he can test it in one of our development builds.
Hide
Jason Clawson added a comment - 20/Apr/10 11:22 AM

I can test it if it makes it into the dev snapshot.

Show
Jason Clawson added a comment - 20/Apr/10 11:22 AM I can test it if it makes it into the dev snapshot.
Hide
David Marginian added a comment - 24/Apr/10 12:08 PM

Thank you Jason. Sorry this took so long. I just applied the patch and checked it in. It is in the latest dev build (79):
http://ci.directwebremoting.org/bamboo/browse/DWR-TRUNK-79/artifact

Show
David Marginian added a comment - 24/Apr/10 12:08 PM Thank you Jason. Sorry this took so long. I just applied the patch and checked it in. It is in the latest dev build (79): http://ci.directwebremoting.org/bamboo/browse/DWR-TRUNK-79/artifact
Hide
David Marginian added a comment - 12/Aug/10 5:32 AM

Anyone?

Show
David Marginian added a comment - 12/Aug/10 5:32 AM Anyone?

People

Dates

  • Created:
    13/Sep/09 1:42 PM
    Updated:
    23/Dec/10 9:47 PM