[ 
https://issues.apache.org/jira/browse/CXF-7267?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15897178#comment-15897178
 ] 

Daniel H. Peger commented on CXF-7267:
--------------------------------------

Giving it a second though, you're probably right. There need to be accessors 
for the fields and one somehow needs to link the methods to the fields, if the 
field is annotated. But maybe you could enhance the logging to some extend by 
putting out a warning, if you encountered an annotated field without a matching 
accessor. As this restriction is not obvious and not documented (at least I did 
not find any corresponding resources), it is somewhat hard to figure out what 
is going wrong. And debugging CXF to know how to do things right, should only 
be the very last resort.

> Member names must match bean attribute for BeanParam to work
> ------------------------------------------------------------
>
>                 Key: CXF-7267
>                 URL: https://issues.apache.org/jira/browse/CXF-7267
>             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(UriBuilderImpl.java:285)
>       at 
> org.apache.cxf.jaxrs.impl.UriBuilderImpl.doBuildUriParts(UriBuilderImpl.java:121)
> ...
> {noformat}
> My parameter bean looked like this:
> {code}package com.recommind.common.rest;
> import javax.ws.rs.PathParam;
> 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
(v6.3.15#6346)

Reply via email to