users@jersey.java.net

Re: [Jersey] wrong method invocation?

From: Ryan Heaton <ryan_at_webcohesion.com>
Date: Wed, 13 Aug 2008 08:44:37 -0600

Yes, thanks!

https://jersey.dev.java.net/issues/show_bug.cgi?id=97

-Ryan


On Wed, Aug 13, 2008 at 4:02 AM, Paul Sandoz <Paul.Sandoz_at_sun.com> wrote:
> Hi Ryan,
>
> This was not by particular design, it was just the way i happened to
> implement it. So i think we could do the following: if a method is annotated
> on a interface and obeys the JAX-RS rules, namely that the implementation
> method has no conflicting annotations (in which case the implementation
> method takes precedence), then cache and use the interface Method instance
> rather than the implementation Method instance. Could you log an issue?
>
> Note that if you want injection onto fields to work then the
> ComponentProvider implementation needs to return the concrete implementation
> for the method ComponentProvider.getInjectableInstance().
>
> Thanks,
> Paul.
>
> Ryan Heaton wrote:
>>
>> Hello.
>>
>> I'm experimenting with the ComponentProvider interface and attempting
>> to return a dynamic proxy as the instance from those "getInstance"
>> methods. The root resource class implements a method on an interface
>> that is annotated with @GET. The dynamic proxy is applied to this
>> interface and eventually delegates its logic to the implementation
>> method.
>>
>> However, it appears that Jersey is invoking the *implementation*
>> method, not the interface method, which actually defines the REST
>> interface (since that's where the annotations reside). Is this by
>> design?
>>
>> java.lang.IllegalArgumentException: object is not an instance of declaring
>> class
>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>> at
>> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>> at
>> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>> at java.lang.reflect.Method.invoke(Method.java:597)
>> at
>> com.sun.jersey.impl.model.method.dispatch.EntityParamDispatchProvider$TypeOutInvoker._dispatch(EntityParamDispatchProvider.java:136)
>> at
>> com.sun.jersey.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:81)
>> at
>> com.sun.jersey.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:133)
>> at
>> com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
>> at
>> com.sun.jersey.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:71)
>> at
>> com.sun.jersey.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:111)
>> at
>> com.sun.jersey.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:64)
>> at
>> com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:720)
>> at
>> com.sun.jersey.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:690)
>>
>> Thanks,
>>
>> -Ryan
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
>> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>>
>
> --
> | ? + ? = To question
> ----------------\
> Paul Sandoz
> x38109
> +33-4-76188109
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_jersey.dev.java.net
> For additional commands, e-mail: users-help_at_jersey.dev.java.net
>
>