[ https://issues.apache.org/jira/browse/CXF-5858?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14074303#comment-14074303 ]
Sergey Beryozkin edited comment on CXF-5858 at 7/25/14 11:31 AM: ----------------------------------------------------------------- Hi, thanks for creating a test project. I run it with CXF 3.1.0-SNAPSHOT, disabled the tests, deployed the war into Tomcat, and then run the test where Criteria is built (I changed the context name to "cxf-rest" and port to "8080", enabled the registration of the param converter) and it passed. I've found why registering the param converter makes a difference. The param converter returns the correct JSON representation, starting with '{', followed by a double quote, followed by the property name, etc. Criteria.toString() returns a string starting from '{' and then followed immediately by the property name. In the latter case CXF UriTemplate thinks it is a proper template variable and does not encode '{'. In the former it does not recognize the sequence as a template var and encodes '{} too and thus the invocation proceeds. I think the fact that UriTemplate treats {noformat} {"a":"b"} {noformat} and {noformat} {a:"b"} {noformat} differently is a UriTemplate bug and as such, with or without ParamConverterProvider the invocation should've failed. Unless the client code does take care of encoding '{' itself. So to summarize: get your ParamConverterProvider encode '{' and '}' because when these characters get submitted as is CXF should always treat it as a template variable. I'll deal with the UriTemplate issue to make sure it is enforced asap was (Author: sergey_beryozkin): Hi, thanks for creating a test project. I run it with CXF 3.1.0-SNAPSHOT, disabled the tests, deployed the war into Tomcat, and then run the test where Criteria is built (I changed the context name to "cxf-rest" and port to "8080", enabled the registration of the param converter) and it passed. I've found why registering the param converter makes a difference. The param converter returns the correct JSON representation, starting with '{', followed by a double quote, followed by the property name, etc. Criteria.toString() returns a string starting from '{' and then followed immediately by the property name. In the latter case CXF UriTemplate things it is a proper template variable and does not encode '{'. In the former it does not recognize the sequence as a template var and encodes '{} too and thus the invocation proceeds. I think the fact that UriTemplate treats {noformat} {"a":"b"} {noformat} and {noformat} {a:"b"} {noformat} differently is a UriTemplate bug and as such, with or without ParamConverterProvider the invocation should've failed. Unless the client code does take care of encoding '{' itself. So to summarize: get your ParamConverterProvider to encode '{' and '}' because when these characters get submitted as is CXF should always treat it as a template variable. I'll deal with the UriTemplate issue to make sure it is enforced asap > WebClient using GET with complex query param object : > IllegalArgumentException: Unresolved variables; only 0 value(s) given for 1 > unique variable(s) > ---------------------------------------------------------------------------------------------------------------------------------------------------- > > Key: CXF-5858 > URL: https://issues.apache.org/jira/browse/CXF-5858 > Project: CXF > Issue Type: Bug > Affects Versions: 2.7.11, 3.0.0 > Reporter: julien Bordeneuve > > Hi, > I use the CXF WebClient to GET a message to a server with a complex query , > this code work on CXF 2.5.x but after a complete version upgrade to CXF 3.0.0 > (also try on 2.7.11). I obtain this exception IllegalArgumentException: > Unresolved variables; only 0 value(s) given for 1 unique variable(s). > The problem seems to be on the URITemplate when CurlyBraceTokenizer parse > the query. > for example for my query : > criteria={destination:"Paris", arrivalDate:"20/11/2014", nbNight:"2", > nbAdult:"1", nbChild:"0", nbRoom:"null"}, > The CurlyBraceTokenizer parser split it like this : > variable = destination > value = "Paris", arrivalDate:"20/11/2014", nbNight:"2", nbAdult:"1", > nbChild:"0", nbRoom:"null" > client side : > " > final List<Object> providers = new ArrayList<Object>(); > providers.add(new JacksonJaxbJsonProvider()); > // providers.add(new ParamConverterProviderImpl()); > WebClient client = WebClient.create( > > "http://localhost:8090/rest-cxf_v2.7.11/API/REST/POC/", providers); > client = > client.accept("application/json").type("application/json") > .path("/bookingServices/getHotelByCriteria"); > client.resetQuery(); > > final Criteria criteria = new Criteria(); > criteria.setDestination("Paris"); > criteria.setArrivalDate("20/11/2014"); > criteria.setNbNight("2"); > criteria.setNbAdult("1"); > criteria.setNbChild("2"); > criteria.setNbRoom("1"); > client.query("criteria", criteria); > > client.getCurrentURI(); > > @SuppressWarnings("unchecked") > final List<Hotel> hotels = (List<Hotel>) client > .getCollection(Hotel.class); > assertThat(hotels).isNotNull(); > } > " > server side : > @GET > @Consumes({ MediaType.APPLICATION_JSON }) > @Produces({ MediaType.APPLICATION_JSON }) > @Path("/getHotelByCriteria") > public List<Hotel> getHotelByCriteria (@QueryParam("criteria") final > Criteria criteria) > { > } -- This message was sent by Atlassian JIRA (v6.2#6252)