0

We are using Restful web services in our project. I am passing object of below class to my webservice as Query parameter.

public class QueryDTO {
    private String name;
    private Object[] args;
    private Object[] results;
//with setters and getters
}

Here is my webservice configuration

@GET
@Produces("application/json")
@Path("/")
QueryDTO executeQuery(@QueryParam("") QueryDTO queryDTO) throws Exception;

Here args may contain any of datatypes(String,Interger,Date ..etc ) When I call

rest/query?name="getCreativeExtractorPatternByName"&args={"473"}

I am getting below exception.

Parameter Class java.lang.Object has no constructor with single String parameter, static valueOf(String) or fromString(String) methods

Please help me in resolving this..

2
  • i dont think you can give an array in the query parameters, thats why exception comes up ! and also you dont need to put the values in double quotes for query params Commented Aug 6, 2012 at 12:53
  • see this for array : stackoverflow.com/questions/5484209/… Commented Aug 6, 2012 at 12:55

1 Answer 1

0

Add a single argument construtor:

public QueryDTO(String name) {
  this.name = name;
}

For injecting the parameters into your DTO object, it should consist a constructor accepting a String parameter.

You should provide a valid Query Parameter for successful injection in your DTO object.

Sign up to request clarification or add additional context in comments.

1 Comment

Can you please explain me , why we need this? Meanwhile, i will try with it and let you know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.