Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 4F330200C3E for ; Mon, 6 Mar 2017 10:00:48 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 4C2DF160B76; Mon, 6 Mar 2017 09:00:48 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6FED0160B73 for ; Mon, 6 Mar 2017 10:00:47 +0100 (CET) Received: (qmail 71460 invoked by uid 500); 6 Mar 2017 09:00:46 -0000 Mailing-List: contact issues-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list issues@cxf.apache.org Received: (qmail 71449 invoked by uid 99); 6 Mar 2017 09:00:46 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Mar 2017 09:00:46 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 24447C0C0D for ; Mon, 6 Mar 2017 09:00:46 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -1.547 X-Spam-Level: X-Spam-Status: No, score=-1.547 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-2.999, SPF_NEUTRAL=0.652] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 7pTEbx7Fm6zu for ; Mon, 6 Mar 2017 09:00:44 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 6432F5FC81 for ; Mon, 6 Mar 2017 09:00:44 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 91F20E0A12 for ; Mon, 6 Mar 2017 09:00:42 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id F268D24186 for ; Mon, 6 Mar 2017 09:00:41 +0000 (UTC) Date: Mon, 6 Mar 2017 09:00:41 +0000 (UTC) From: "Daniel H. Peger (JIRA)" To: issues@cxf.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CXF-7267) Member names must match bean attribute for BeanParam to work MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Mon, 06 Mar 2017 09:00:48 -0000 [ https://issues.apache.org/jira/browse/CXF-7267?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Daniel H. Peger updated CXF-7267: --------------------------------- Description: 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. was: 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. > 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)