cxf-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sergey Beryozkin (JIRA)" <>
Subject [jira] [Commented] (CXF-7267) Member names must match bean attribute for BeanParam to work
Date Mon, 06 Mar 2017 14:54:32 GMT


Sergey Beryozkin commented on CXF-7267:

Well in the end I decided to relax it a bit and fix it, the setters must still be available
just to have a bean style supported, but if no match between a setter name and a field name
is found then there will be the last branch running checking all the fields. I suppose there
indeed could be cases where due to the naming conventions/preferences or when 3rd party library
beans are used, when no match can be found. There've been a number of issues reported specifically
around this restriction over the last few years, so I guess the time has come just to get
it fixed; though I'd recommend, if one has such an option, just to make the match work or
annotate the methods which will be faster...


> Member names must match bean attribute for BeanParam to work
> ------------------------------------------------------------
>                 Key: CXF-7267
>                 URL:
>             Project: CXF
>          Issue Type: Bug
>    Affects Versions: 3.1.4
>            Reporter: Daniel H. Peger
>            Priority: Minor
> I just ran into this problem on my first attempt to use {{@BeanParam}} and got this exception:
> {noformat}
> java.lang.IllegalArgumentException: Unresolved variables; only 0 value(s) given for 2
unique variable(s)
> 	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.substituteVarargs(
> 	at org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuildUriParts(
> ...
> {noformat}
> My parameter bean looked like this:
> {code}package;
> import;
> public final class ApplicationIdentifierParameter
> {
>   @PathParam("applicationId")
>   private String mApplicationId;
>   @PathParam("projectId")
>   private String mProjectId;
>   public String getApplicationId()
>   {
>     return mApplicationId;
>   }
>   public void setApplicationId(String aApplicationId)
>   {
>     mApplicationId = aApplicationId;
>   }
>   public String getProjectId()
>   {
>     return mProjectId;
>   }
>   public void setProjectId(String aProjectId)
>   {
>     mProjectId = aProjectId;
>   }
> }
> {code}
> I debugged {{UriBuilderImpl}} and found that in {{ClientProxyImpl:514}} the to be evaluated
members are identified by the names of the corresponding setters.
> I think this is wrong - or at least inconvenient - as it is totally valid for a bean's
internals fields to have different names than the corresponding bean attribute. To my knowledge
the Bean spec only requires setters and getters to match and does not care about the internal
representation of the attributes.
> Rather than looking at the setters {{ClientProxyImpl}} should iterate over the bean's
fields, look for fields annotated with {{@PathParam}} and update the field using reflection.
> *Workaround:*
> Annotate the setters with the {{@XXXParam}} annotations.

This message was sent by Atlassian JIRA

View raw message