Hi Michael,
Jersey 2.0 doesn't support Guice. See
https://java.net/jira/browse/JERSEY-1950
Gili
On 24/02/2014 5:11 AM, Michael Delamere wrote:
>
> Hi all,
>
> I am having problems integrating guice in jersey. Basically when I try
> to populate the bean "DefaultRole" (interface "Role") using injection
> with @InjectParam the implementation class "DefaultRole" gets
> instantiated, but not populated. When I leave out @InjectParam and
> just use the implementation class directly in the method signature
> instead of the interface, it works perfectly.
>
> This is the request that I am sending off via POST:
>
> {"id":12345,"permissions":["READ_XX","WRITE_XX"]}
>
> The following implementation DOES NOT work where I am using the bean
> interface as the parameter:
>
> @POST
>
> @Produces({ MediaType./APPLICATION_JSON/, MediaType./APPLICATION_XML/})
>
> @Consumes({ MediaType./APPLICATION_JSON/, MediaType./APPLICATION_XML/})
>
> *public*Role processLogin*(**_at_InjectParam**Role role*)
> *throws*JSONException
>
> {
>
> System./out/.println(role);
>
> *return*role;
>
> }
>
> The following implementation WORKS where I am using the bean
> implementation as the parameter:
>
> @POST
>
> @Produces({ MediaType./APPLICATION_JSON/, MediaType./APPLICATION_XML/})
>
> @Consumes({ MediaType./APPLICATION_JSON/, MediaType./APPLICATION_XML/})
>
> *public*Role processLogin(*DefaultRole role*) *throws*JSONException
>
> {
>
> System./out/.println(role);
>
> *return*role;
>
> }
>
> Unfortunately this is of course not what I want because I want to be
> able to use my interfaces and have them injected via jersey/guice.
>
> Can anyone help me on this? What could I be doing wrong?
>
> Thanks and best regards,
>
> Michael
>