You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by arjjun dhar <dh...@yahoo.com> on 2013/02/25 02:08:41 UTC

jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

I have a very simple setup, where I have a JaxRS CLient defined by:



And on server side:


But when upgrading to even 2.5.4; I get the follwoing exception when
invoking a method on my Proxy Client:


The reason for this on debugging is:


It seems to expect the Parameter Object to provide a mechanism to convert
STRING to Object. Which would have been acceptable if I had no provider. I
do have a class for marshalling. ANd it worked until now

Can someone explain? I looked at the API and the XML config and see nothings
really changed there so I'm not sure why this is breaking. 

thanks




--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 14/05/13 06:54, arjjun dhar wrote:
> Problem was solved and I was also now able to upgrade.
> The following notes applied to this problem...
>
> 1. ParameterHandlers are the lowest grade citizens for param mapping and it
> can be frustrating to figure out what else is getting in the way before it
> reaches the Handler; if multiple providers are provided and one is
> leveraging some common aspects between the providers. ..Example: The
> provider TYPE's are very similar only subtly different.
>

FYI, in CXF 2.8.0, where CXF specific ParameterHandlers have actually 
been removed, the JAX-RS 2.0 ParameterConverters will be checked first, 
before the default mechanism of converting various URI parts into 
parameters is used.
> 2. While the documentation states one can have the same class implement both
> MessageBodyReaders and ParameterHandlers, it can lead to a lot of trouble.
> Its possible but better avoidable .. infact I think it should be discouraged
> (personal opinion for keeping a simpler cleaner design).
>
Well, I'm fine with your preferring not to have a single handler class 
implementing both MessageBodyReader & ParameterHandler, just note that 
MessageBodyReader & ParameterHandler deal with completely different 
parts of the request, so while keeping the implementations separately 
may indeed be a good idea having a combined implementation has to work 
as if it were 2 different implementations

> ... as a result, Im giving up the use of ParameterHandler and its got me a
> cleaner predictable design/code now and it all works without any magic.
>
Yes, having simple parameter types indeed makes things simpler

Cheers, Sergey

> Thanks for all your help.
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5727623.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by arjjun dhar <dh...@yahoo.com>.
Problem was solved and I was also now able to upgrade. 
The following notes applied to this problem...

1. ParameterHandlers are the lowest grade citizens for param mapping and it
can be frustrating to figure out what else is getting in the way before it
reaches the Handler; if multiple providers are provided and one is
leveraging some common aspects between the providers. ..Example: The
provider TYPE's are very similar only subtly different.

2. While the documentation states one can have the same class implement both
MessageBodyReaders and ParameterHandlers, it can lead to a lot of trouble.
Its possible but better avoidable .. infact I think it should be discouraged
(personal opinion for keeping a simpler cleaner design).

... as a result, Im giving up the use of ParameterHandler and its got me a
cleaner predictable design/code now and it all works without any magic.

Thanks for all your help.



--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5727623.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by arjjun dhar <dh...@yahoo.com>.
My bad, I have these classes that implement both


While developing, i found some common aspects and decided to bundle them
into adapters that are polymorphic in nature.  Hence i have managed to
confuse myself.

Sorry, i'll clean an figure this out. 
thank you for your responses.



--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5727580.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 12/05/13 18:53, arjjun dhar wrote:
> I think I realize the issue ... when you provide multiple MessageBodyReader's
> under<jaxrs:providers>; it filters the provider by first matching MediaType
> (See {@link ProviderFactory#chooseMessageReader} ). (I dont understand why
> .. because its likely many WebService end points may have the same MediaType
> but different parameter (Object ) types .. so it picks the first one that
> matches always. I was also hoping "MessageBodyReader.isReadable(...)" ..
> would provide some filtering abilites, but looks like thats only called in a
> specific condition. And provides no real filtering ability.
>
> I've had to hack my way around this. I cant be the bright way so am sure in
> terms of configuring my providers Im doing something wrong. ... Is MEDIA
> TYPE  the only filter for which Provider is used?
>
> Wierd !!
>

You've been asking about ParameterConverters as far as I recall. 
MessageBodyReaders are not even taken into consideration when processing 
the parameters (those annotated with @PathParam, etc), they are only 
used to handle typically a single method parameter representing a 
request/message body.

MBR.isReadable is checked, furthermore, the class a given MBR is typed 
upon is also checked, in 2.7.x it is a secondary key, in 2.8.0 - a 
primary key, media type - secondary key

Sergey

>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5727562.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by arjjun dhar <dh...@yahoo.com>.
I think I realize the issue ... when you provide multiple MessageBodyReader's
under <jaxrs:providers>; it filters the provider by first matching MediaType
(See {@link ProviderFactory#chooseMessageReader} ). (I dont understand why
.. because its likely many WebService end points may have the same MediaType
but different parameter (Object ) types .. so it picks the first one that
matches always. I was also hoping "MessageBodyReader.isReadable(...)" ..
would provide some filtering abilites, but looks like thats only called in a
specific condition. And provides no real filtering ability.

I've had to hack my way around this. I cant be the bright way so am sure in
terms of configuring my providers Im doing something wrong. ... Is MEDIA
TYPE  the only filter for which Provider is used?

Wierd !!



--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5727562.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Sergey Beryozkin <sb...@gmail.com>.
On 04/03/13 09:36, arjjun dhar wrote:
> ... Any update on this ?
> Thanks
>
Can you have a look at

http://svn.apache.org/r1452244

which adds one more ParameterHandler test in addition to

http://svn.apache.org/r1452235

which tests 2.0 ParameterConverter

What is different in your case ?

Cheers, Sergey

>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5723995.html
> Sent from the cxf-user mailing list archive at Nabble.com.


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by arjjun dhar <dh...@yahoo.com>.
... Any update on this ?
Thanks



--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5723995.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by arjjun dhar <dh...@yahoo.com>.
Sure (thanks for responding)

Query Class : 


Service class GenericObjectQueryService :


So say I want to execute count(Query) that fails and gives me wat I
explained above.


thanks



--
View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630p5723766.html
Sent from the cxf-user mailing list archive at Nabble.com.

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi Freeman
On 25/02/13 10:31, Freeman Fang wrote:
> Hi Sergey,
>
> Just a reminder, using nabble[1] url directly can see the exception.
>
> Seems nabble forum always filter something
>
> [1]http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-td5723630.html
>
Thanks, that helped.

Ok, then, the issue occurs on the server side,
Arjjun, so

<bean id="queryJSONReaderProvider" class="...QueryReader" />

is ParameterHandler for "com.neurosys.domain.Query", is that right ?

Can you please type the method signature so that I can try and reproduce ?

Cheers, Sergey


> Best Regards
> -------------
> Freeman(Yue) Fang
>
> Red Hat, Inc.
> FuseSource is now part of Red Hat
> Web: http://fusesource.com | http://www.redhat.com/
> Twitter: freemanfang
> Blog: http://freemanfang.blogspot.com
> http://blog.sina.com.cn/u/1473905042
> weibo: @Freeman小屋
>
> On 2013-2-25, at 下午6:03, Sergey Beryozkin wrote:
>
>> Hi
>>
>> No sample code or exception traces are visible, can you resend please
>>
>> Sergey
>>
>> On 25/02/13 01:08, arjjun dhar wrote:
>>> I have a very simple setup, where I have a JaxRS CLient defined by:
>>>
>>>
>>>
>>> And on server side:
>>>
>>>
>>> But when upgrading to even 2.5.4; I get the follwoing exception when
>>> invoking a method on my Proxy Client:
>>>
>>>
>>> The reason for this on debugging is:
>>>
>>>
>>> It seems to expect the Parameter Object to provide a mechanism to convert
>>> STRING to Object. Which would have been acceptable if I had no provider. I
>>> do have a class for marshalling. ANd it worked until now
>>>
>>> Can someone explain? I looked at the API and the XML config and see nothings
>>> really changed there so I'm not sure why this is breaking.
>>>
>>> thanks
>>>
>>>
>>>
>>>
>>> --
>>> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630.html
>>> Sent from the cxf-user mailing list archive at Nabble.com.
>>
>
>


-- 
Sergey Beryozkin

Talend Community Coders
http://coders.talend.com/

Blog: http://sberyozkin.blogspot.com

Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Freeman Fang <fr...@gmail.com>.
Hi Sergey,

Just a reminder, using nabble[1] url directly can see the exception.

Seems nabble forum always filter something

[1]http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-td5723630.html

Best Regards
-------------
Freeman(Yue) Fang

Red Hat, Inc. 
FuseSource is now part of Red Hat
Web: http://fusesource.com | http://www.redhat.com/
Twitter: freemanfang
Blog: http://freemanfang.blogspot.com
http://blog.sina.com.cn/u/1473905042
weibo: @Freeman小屋

On 2013-2-25, at 下午6:03, Sergey Beryozkin wrote:

> Hi
> 
> No sample code or exception traces are visible, can you resend please
> 
> Sergey
> 
> On 25/02/13 01:08, arjjun dhar wrote:
>> I have a very simple setup, where I have a JaxRS CLient defined by:
>> 
>> 
>> 
>> And on server side:
>> 
>> 
>> But when upgrading to even 2.5.4; I get the follwoing exception when
>> invoking a method on my Proxy Client:
>> 
>> 
>> The reason for this on debugging is:
>> 
>> 
>> It seems to expect the Parameter Object to provide a mechanism to convert
>> STRING to Object. Which would have been acceptable if I had no provider. I
>> do have a class for marshalling. ANd it worked until now
>> 
>> Can someone explain? I looked at the API and the XML config and see nothings
>> really changed there so I'm not sure why this is breaking.
>> 
>> thanks
>> 
>> 
>> 
>> 
>> --
>> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630.html
>> Sent from the cxf-user mailing list archive at Nabble.com.
> 


Re: jaxrs:providers not respected when migrating from 2.5.2 to 2.7.x

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi

No sample code or exception traces are visible, can you resend please

Sergey

On 25/02/13 01:08, arjjun dhar wrote:
> I have a very simple setup, where I have a JaxRS CLient defined by:
>
>
>
> And on server side:
>
>
> But when upgrading to even 2.5.4; I get the follwoing exception when
> invoking a method on my Proxy Client:
>
>
> The reason for this on debugging is:
>
>
> It seems to expect the Parameter Object to provide a mechanism to convert
> STRING to Object. Which would have been acceptable if I had no provider. I
> do have a class for marshalling. ANd it worked until now
>
> Can someone explain? I looked at the API and the XML config and see nothings
> really changed there so I'm not sure why this is breaking.
>
> thanks
>
>
>
>
> --
> View this message in context: http://cxf.547215.n5.nabble.com/jaxrs-providers-not-respected-when-migrating-from-2-5-2-to-2-7-x-tp5723630.html
> Sent from the cxf-user mailing list archive at Nabble.com.