You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@cxf.apache.org by Francesco Chicchiriccò <il...@apache.org> on 2015/04/23 13:56:08 UTC

Using @BeanParam

Hi,
with reference to the solutions proposed in this thread [1] to avoid 
forcing client code passing null parameters, I am exploring @BeanParam.

I have now UserService (an interface) with a brand new list() method like as

     @GET
     @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
     PagedResult<UserTO> list(@BeanParam ListQuery listQuery);

and my ListQuery bean is as [2].

Now, when invoking

http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd

I received an error 500:

[...]
Caused by: java.lang.AbstractMethodError: 
org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult;

If I check the URL generated by client code for

         ListQuery lq = new ListQuery();
         lq.setRealms(Arrays.asList("/even/two", "/odd"));

I see that

http://localhost:9080/syncope/rest/users

is generated (e.g. without realms).

What am I doing wrong?
TIA

Regards.

[1] 
http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html
[2] https://paste.apache.org/aHaK

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/



Re: Using @BeanParam

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 23/04/2015 14:28, Sergey Beryozkin wrote:
> Hi
> On 23/04/15 13:21, Francesco Chicchiriccò wrote:
>> On 23/04/2015 14:17, Sergey Beryozkin wrote:
>>> Hi,
>>>
>>> I've checked the code, right now only annotations on the BeanParam
>>> bean setters are recognized on the client side so if you move them
>>> from fields to setters then it will work. I believe I did fix the
>>> server side code awhile back to check BeanParam bean fields too but
>>> haven't updated the client proxy code.
>>> So, another workaround is needed for now :-)
>>
>> Ok, this explains the client-side error, but what about the
>> AbstractMethodError I got when sending a manual request to
>>
>> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd 
>>
>>
> I suspect the old method signature is still visible somewhere at a JVM 
> level ?

Doh... after moving JAX-RS annotations to setter methods, things now 
seem to work fine.

FYI the former

userService.list(Arrays.asList("/even/two", "/odd"), null, null, null);

now is

userService.list(SyncopeClient.getSubjectListQueryBuilder().realm("/even/two").realm("/odd").build());

which looks far better, isn't it?

Regards.

>>> On 23/04/15 12:56, Francesco Chicchiriccò wrote:
>>>> Hi,
>>>> with reference to the solutions proposed in this thread [1] to avoid
>>>> forcing client code passing null parameters, I am exploring 
>>>> @BeanParam.
>>>>
>>>> I have now UserService (an interface) with a brand new list() method
>>>> like as
>>>>
>>>>      @GET
>>>>      @Produces({ MediaType.APPLICATION_XML,
>>>> MediaType.APPLICATION_JSON })
>>>>      PagedResult<UserTO> list(@BeanParam ListQuery listQuery);
>>>>
>>>> and my ListQuery bean is as [2].
>>>>
>>>> Now, when invoking
>>>>
>>>> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd 
>>>>
>>>>
>>>>
>>>> I received an error 500:
>>>>
>>>> [...]
>>>> Caused by: java.lang.AbstractMethodError:
>>>> org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult; 
>>>>
>>>>
>>>>
>>>>
>>>> If I check the URL generated by client code for
>>>>
>>>>          ListQuery lq = new ListQuery();
>>>>          lq.setRealms(Arrays.asList("/even/two", "/odd"));
>>>>
>>>> I see that
>>>>
>>>> http://localhost:9080/syncope/rest/users
>>>>
>>>> is generated (e.g. without realms).
>>>>
>>>> What am I doing wrong?
>>>> TIA
>>>>
>>>> Regards.
>>>>
>>>> [1] 
>>>> http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html 
>>>>
>>>>
>>>> [2] https://paste.apache.org/aHaK

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/



Re: Using @BeanParam

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 23/04/15 13:21, Francesco Chicchiriccò wrote:
> On 23/04/2015 14:17, Sergey Beryozkin wrote:
>> Hi,
>>
>> I've checked the code, right now only annotations on the BeanParam
>> bean setters are recognized on the client side so if you move them
>> from fields to setters then it will work. I believe I did fix the
>> server side code awhile back to check BeanParam bean fields too but
>> haven't updated the client proxy code.
>> So, another workaround is needed for now :-)
>
> Ok, this explains the client-side error, but what about the
> AbstractMethodError I got when sending a manual request to
>
> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd
>
I suspect the old method signature is still visible somewhere at a JVM 
level ?

Cheers, Sergey

> ?
>
>> On 23/04/15 12:56, Francesco Chicchiriccò wrote:
>>> Hi,
>>> with reference to the solutions proposed in this thread [1] to avoid
>>> forcing client code passing null parameters, I am exploring @BeanParam.
>>>
>>> I have now UserService (an interface) with a brand new list() method
>>> like as
>>>
>>>      @GET
>>>      @Produces({ MediaType.APPLICATION_XML,
>>> MediaType.APPLICATION_JSON })
>>>      PagedResult<UserTO> list(@BeanParam ListQuery listQuery);
>>>
>>> and my ListQuery bean is as [2].
>>>
>>> Now, when invoking
>>>
>>> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd
>>>
>>>
>>> I received an error 500:
>>>
>>> [...]
>>> Caused by: java.lang.AbstractMethodError:
>>> org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult;
>>>
>>>
>>>
>>> If I check the URL generated by client code for
>>>
>>>          ListQuery lq = new ListQuery();
>>>          lq.setRealms(Arrays.asList("/even/two", "/odd"));
>>>
>>> I see that
>>>
>>> http://localhost:9080/syncope/rest/users
>>>
>>> is generated (e.g. without realms).
>>>
>>> What am I doing wrong?
>>> TIA
>>>
>>> Regards.
>>>
>>> [1]
>>> http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html
>>>
>>>
>>> [2] https://paste.apache.org/aHaK
>


-- 
Sergey Beryozkin

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

Blog: http://sberyozkin.blogspot.com

Re: Using @BeanParam

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 23/04/2015 14:17, Sergey Beryozkin wrote:
> Hi,
>
> I've checked the code, right now only annotations on the BeanParam 
> bean setters are recognized on the client side so if you move them 
> from fields to setters then it will work. I believe I did fix the 
> server side code awhile back to check BeanParam bean fields too but 
> haven't updated the client proxy code.
> So, another workaround is needed for now :-)

Ok, this explains the client-side error, but what about the 
AbstractMethodError I got when sending a manual request to

http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd

?

> On 23/04/15 12:56, Francesco Chicchiriccò wrote:
>> Hi,
>> with reference to the solutions proposed in this thread [1] to avoid
>> forcing client code passing null parameters, I am exploring @BeanParam.
>>
>> I have now UserService (an interface) with a brand new list() method
>> like as
>>
>>      @GET
>>      @Produces({ MediaType.APPLICATION_XML, 
>> MediaType.APPLICATION_JSON })
>>      PagedResult<UserTO> list(@BeanParam ListQuery listQuery);
>>
>> and my ListQuery bean is as [2].
>>
>> Now, when invoking
>>
>> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd 
>>
>>
>> I received an error 500:
>>
>> [...]
>> Caused by: java.lang.AbstractMethodError:
>> org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult; 
>>
>>
>>
>> If I check the URL generated by client code for
>>
>>          ListQuery lq = new ListQuery();
>>          lq.setRealms(Arrays.asList("/even/two", "/odd"));
>>
>> I see that
>>
>> http://localhost:9080/syncope/rest/users
>>
>> is generated (e.g. without realms).
>>
>> What am I doing wrong?
>> TIA
>>
>> Regards.
>>
>> [1] 
>> http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html 
>>
>>
>> [2] https://paste.apache.org/aHaK

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: Using @BeanParam

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


On 24/04/15 07:39, Francesco Chicchiriccò wrote:
> On 23/04/2015 18:04, Sergey Beryozkin wrote:
>> Hi
>> On 23/04/15 15:42, Francesco Chicchiriccò wrote:
>>> On 23/04/2015 15:03, Sergey Beryozkin wrote:
>>>> Hi Francesco,
>>>>
>>>> Did a basic update of the client proxy code to check BeanParam fields
>>>> so having annotations on fields should work in 3.0.5.
>>>
>>> I've pulled latest changes, build 3.0.5-SNAPSHOT from sources and tried:
>>> sorry, it only works when annotating the setter methods.
>>>
>> That was my fault, I got a bit lazy and thought i could save some time
>> on doing a test :-). Have just added it, alongside with another fix.
>> Should all be OK now
>>
>> http://git-wip-us.apache.org/repos/asf/cxf/commit/cf211b15
>
> Hi,
> it's better, but still problematic: now, when moving annotations from
> setter methods to fields in [1][2][3], I got test exceptions which mean
> that at least "page" and "size" take their default values instead of the
> passed ones.

I guess it might be to do with having a class hierarchy in your case, 
the client proxy does not yet check super classes that may have private 
fields.
Indeed, having the annotations on the setters is not bad at all, but 
I'll check a bit later on if I can make the client proxy code more 
effective (for it to check the super class private fields),

thanks, Sergey

>
> Thoughts? (I am fine even as it is ATM, anyway)
>
> Regards.
>
> [1]
> https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ListQuery.java
>
> [2]
> https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SubjectListQuery.java
>
> [3]
> https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SubjectSearchQuery.java
>
>


Re: Using @BeanParam

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 23/04/2015 18:04, Sergey Beryozkin wrote:
> Hi
> On 23/04/15 15:42, Francesco Chicchiriccò wrote:
>> On 23/04/2015 15:03, Sergey Beryozkin wrote:
>>> Hi Francesco,
>>>
>>> Did a basic update of the client proxy code to check BeanParam fields
>>> so having annotations on fields should work in 3.0.5.
>>
>> I've pulled latest changes, build 3.0.5-SNAPSHOT from sources and tried:
>> sorry, it only works when annotating the setter methods.
>>
> That was my fault, I got a bit lazy and thought i could save some time 
> on doing a test :-). Have just added it, alongside with another fix. 
> Should all be OK now
>
> http://git-wip-us.apache.org/repos/asf/cxf/commit/cf211b15

Hi,
it's better, but still problematic: now, when moving annotations from 
setter methods to fields in [1][2][3], I got test exceptions which mean 
that at least "page" and "size" take their default values instead of the 
passed ones.

Thoughts? (I am fine even as it is ATM, anyway)

Regards.

[1] 
https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/ListQuery.java
[2] 
https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SubjectListQuery.java
[3] 
https://github.com/apache/syncope/blob/master/common/rest-api/src/main/java/org/apache/syncope/common/rest/api/beans/SubjectSearchQuery.java

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: Using @BeanParam

Posted by Sergey Beryozkin <sb...@gmail.com>.
Hi
On 23/04/15 15:42, Francesco Chicchiriccò wrote:
> On 23/04/2015 15:03, Sergey Beryozkin wrote:
>> Hi Francesco,
>>
>> Did a basic update of the client proxy code to check BeanParam fields
>> so having annotations on fields should work in 3.0.5.
>
> I've pulled latest changes, build 3.0.5-SNAPSHOT from sources and tried:
> sorry, it only works when annotating the setter methods.
>
That was my fault, I got a bit lazy and thought i could save some time 
on doing a test :-). Have just added it, alongside with another fix. 
Should all be OK now

http://git-wip-us.apache.org/repos/asf/cxf/commit/cf211b15

Thanks. Sergey

> Regards.
>


Re: Using @BeanParam

Posted by Francesco Chicchiriccò <il...@apache.org>.
On 23/04/2015 15:03, Sergey Beryozkin wrote:
> Hi Francesco,
>
> Did a basic update of the client proxy code to check BeanParam fields 
> so having annotations on fields should work in 3.0.5.

I've pulled latest changes, build 3.0.5-SNAPSHOT from sources and tried: 
sorry, it only works when annotating the setter methods.

Regards.

-- 
Francesco Chicchiriccò

Tirasa - Open Source Excellence
http://www.tirasa.net/

Involved at The Apache Software Foundation:
member, Syncope PMC chair, Cocoon PMC, Olingo PMC
http://people.apache.org/~ilgrosso/


Re: Using @BeanParam

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

Did a basic update of the client proxy code to check BeanParam fields so 
having annotations on fields should work in 3.0.5.

Sergey
On 23/04/15 13:17, Sergey Beryozkin wrote:
> Hi,
>
> I've checked the code, right now only annotations on the BeanParam bean
> setters are recognized on the client side so if you move them from
> fields to setters then it will work. I believe I did fix the server side
> code awhile back to check BeanParam bean fields too but haven't updated
> the client proxy code.
> So, another workaround is needed for now :-)
>
> Thanks, Sergey
>
>
> On 23/04/15 12:56, Francesco Chicchiriccò wrote:
>> Hi,
>> with reference to the solutions proposed in this thread [1] to avoid
>> forcing client code passing null parameters, I am exploring @BeanParam.
>>
>> I have now UserService (an interface) with a brand new list() method
>> like as
>>
>>      @GET
>>      @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>>      PagedResult<UserTO> list(@BeanParam ListQuery listQuery);
>>
>> and my ListQuery bean is as [2].
>>
>> Now, when invoking
>>
>> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd
>>
>> I received an error 500:
>>
>> [...]
>> Caused by: java.lang.AbstractMethodError:
>> org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult;
>>
>>
>>
>> If I check the URL generated by client code for
>>
>>          ListQuery lq = new ListQuery();
>>          lq.setRealms(Arrays.asList("/even/two", "/odd"));
>>
>> I see that
>>
>> http://localhost:9080/syncope/rest/users
>>
>> is generated (e.g. without realms).
>>
>> What am I doing wrong?
>> TIA
>>
>> Regards.
>>
>> [1]
>> http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html
>>
>>
>> [2] https://paste.apache.org/aHaK
>>
>


Re: Using @BeanParam

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

I've checked the code, right now only annotations on the BeanParam bean 
setters are recognized on the client side so if you move them from 
fields to setters then it will work. I believe I did fix the server side 
code awhile back to check BeanParam bean fields too but haven't updated 
the client proxy code.
So, another workaround is needed for now :-)

Thanks, Sergey


On 23/04/15 12:56, Francesco Chicchiriccò wrote:
> Hi,
> with reference to the solutions proposed in this thread [1] to avoid
> forcing client code passing null parameters, I am exploring @BeanParam.
>
> I have now UserService (an interface) with a brand new list() method
> like as
>
>      @GET
>      @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
>      PagedResult<UserTO> list(@BeanParam ListQuery listQuery);
>
> and my ListQuery bean is as [2].
>
> Now, when invoking
>
> http://localhost:9080/syncope/rest/users;realm=%2Feven%2Ftwo;realm=%2Fodd
>
> I received an error 500:
>
> [...]
> Caused by: java.lang.AbstractMethodError:
> org.apache.syncope.core.rest.cxf.service.UserServiceImpl.list(Lorg/apache/syncope/common/rest/api/beans/ListQuery;)Lorg/apache/syncope/common/lib/to/PagedResult;
>
>
> If I check the URL generated by client code for
>
>          ListQuery lq = new ListQuery();
>          lq.setRealms(Arrays.asList("/even/two", "/odd"));
>
> I see that
>
> http://localhost:9080/syncope/rest/users
>
> is generated (e.g. without realms).
>
> What am I doing wrong?
> TIA
>
> Regards.
>
> [1]
> http://cxf.547215.n5.nabble.com/JAX-RS-Matrix-parameters-and-method-matching-tp5756387p5756414.html
>
> [2] https://paste.apache.org/aHaK
>