0

I am trying to use Jersey's @BeanParam annotation the following way:

This is my bean:

public class BeanParamModel {

@QueryParam(value = "param1")
private String param1;

public BeanParamModel(@QueryParam("param1") String param1) {
    this.param1 = param1;
}

public String getParam1() {
    return param1;
}

public void setParam1(String param1) {
    this.param1 = param1;
}}

And this is the resource method that needs to use it:

@Consumes("*/*")
@Path("mypath")
@GET
public Response getUpgradeStatus(@QueryParam("param1") String param1, @BeanParam BeanParamModel user) {
    return Response.ok().build();
}

Now I want to test this using a unit test which sends an http request to a test server with the following url:

GET http://path_to_resource?param1=1

My problem is that results in a 415 response with Jersey printing this message:

A message body reader for Java class BeanParamModel, and Java type class BeanParamModel, and MIME media type application/octet-stream was not found. The registered message body readers compatible with the MIME media type are:...

I've trying adding a "application/x-www-form-urlencoded" header but the message repeats for that header type as well. I also tried using an application/json header, this results in EOF expection from the jackson mapper due to end of input.

Can anyone tell me what I'm not doing correctly? from the jersey documentation of @BeanParam it seems pretty simple.

Anat
  • 1
  • 1
  • 2
  • Why are you consuming `*/*`?. Do you understand the implication of that for your application? – Paul Samsotha Jul 01 '16 at 00:35
  • The code above is a simplified version of a resource to demonstrate the issue I'm having, not the actual application. Regarding the consumption annotation: I have tried consuming application types that conform with the header I'm sending but that no effect, still getting the same errors. – Anat Jul 04 '16 at 08:47

1 Answers1

0

With a @GET you should not have @Consumes.

user3755282
  • 813
  • 2
  • 9
  • 15