users@jersey.java.net

[Jersey] Re: jersey-guice based on spring-guice

From: Marek Potociar <marek.potociar_at_oracle.com>
Date: Tue, 5 Nov 2013 21:47:08 +0100

Hello Gili,

Trying to get the community organized and involved in contributing improvements to Guice and Spring support in HK2 and Jersey 2 is the right step. Please feel free to contribute any new features and/or improvements to current support.

Cheers,
Marek

P.S. As much as I understand why people using Spring and Guice are upset about this, I still do not think it was a mistake to release Jersey 2 without a Spring and Guice support. Jersey now provides JSR-330 injection (via HK2) without any need for Spring or Guice. Also, support for Spring and Guice was not the primary release or feature driver for Jersey. JAX-RS 2.0 support and releasing JAX-RS 2.0 RI was the primary motivation for the earliest possible release.

On 28 Oct 2013, at 03:57, cowwoc <cowwoc_at_bbs.darktech.org> wrote:

> Kariem,
>
> I have tried very hard to add Guice support to Jersey, unfortunately I don't think it is happening. Building an HK2-Guice bridge is very very difficult (perhaps even impossible). I think it was a mistake to release Jersey 2.0 without first testing Guice and Spring support. Spring support was added a few months after the initial release and it still suffers from some pretty serious limitations (inability to inject beans into JAX-RS classes using XML configuration). Guice support is still dead in the water.
>
> I am very frustrated by the fact that all of this worked perfectly in Jersey 1.0. In my opinion, this is a huge step backwards for end-users.
>
> If anyone on this list is highly experienced with HK2 and Guice please contact me and let's try to get this fixed.
>
> Thanks,
> Gili
>
> On 18/10/2013 5:13 AM, Kariem Hussein wrote:
>> Hi,
>>
>> I tried the examples from JERSEY-1957 and another example [2] with limited success. Especially for components that should be created by guice (proxies for transactions) I could not find a good solution.
>>
>> So I thought, I follow the implementation for Spring [3] and do the same for Guice. I have forked the current jersey master on github and added the following modules:
>>
>> - jersey-guice – https://github.com/kariem/jersey/tree/master/ext/guice
>> - example webapp – https://github.com/kariem/jersey/tree/master/examples/helloworld-guice-webapp
>>
>> Still, I have a problem with registering providers (and probably other things like Features), as can be seen, when you try to use the custom exception mapper for IllegalArgumentException on helloworld-guice-webapp/guice-singleton-hello?p1=foobar.
>>
>> Any suggestions? I really don't know HK2, so there might be a few things I have done wrong.
>>
>> Thank you,
>> Kariem
>>
>>
>> [1] https://java.net/jira/browse/JERSEY-1950
>> [2] https://github.com/piersy/jersey2-guice-example-with-test
>> [3] https://java.net/jira/browse/JERSEY-1957, https://github.com/jersey/jersey/tree/master/ext/spring3
>