1

The following is my method signature which I am using in Jersey , when I debug/run the program I am getting error as :

[[FATAL] Method public javax.ws.rs.core.Response com.xxxx.xxxxx.Xxxxx.xxxxx.xxxxxxxx(java.lang.String,java.lang.String,java.lang.String,javax.ws.rs.container.ContainerRequestContext) on resource class com.xxxxxx.xxxxx.xxxxxx.xxxxxx contains multiple parameters with no annotation.

My code:

@PUT
@Path("/user/{user}/{role}")
@Consumes({MediaType.APPLICATION_JSON,MediaType.TEXT_PLAIN})
@Produces("application/json")

public Response myFunction(@PathParam("user") String user,
    @PathParam("role") String role,
    String rawData,
    @Context ContainerRequestContext crc) {

}

What I am doing wrong here.

Thank you

svarog
  • 9,477
  • 4
  • 61
  • 77
Shivkumar Mallesappa
  • 2,875
  • 7
  • 41
  • 68

1 Answers1

1

Edit: This answer helped me solve my error, but as Cássio Mazzochi Molin mentioned in the comment below: it wont help you (and the documentation is for the wrong version of Jersey..). A total miss on my part.

Please excuse my attempt to help you. I hope you already have solved your error :)

Ahoy there!

I'm really new to REST (so take my answer with a bucket of herb salt), but I think I know where your error is coming from.

You have to bind your parameter rawData.

Example: @PathParam("rawdata") String rawData or @HeaderParam("rawdata") String rawData

Depending on where you want to extract the parameter from you have to write a @annotation to the parameter.

You can extract the following types of parameters for use in your resource class:

  • Query
  • URI
  • Path
  • Form
  • Cookie
  • Header
  • Matrix

Text above is taken from the link: http://docs.oracle.com/javaee/6/tutorial/doc/gilik.html You should take a look and read a little about it if you haven't done it already :)

  • **1.** I don't think this part accurate: _You have to_ bind _your parameter `rawData`_. The method is annotated with `@PUT`, hence the `rawData` should be sent in the request payload and no `@___Param` annotation is required. **2.** Jersey 2.x (see the tag in the question) is part of Java EE 7 and the link you provided is from Java EE 6. The documentation is not wrong though. – cassiomolin Oct 17 '16 at 08:31
  • Thank you for correcting me.I had the same problem (but with `@GET`) and this solved my problem. And I didn't know that there could be a difference between `@GET`and `@PUT`. Maybe I should know more about a subject before trying to solve others problems. Lesson learned :) – Karl Evald Wigestrand Oct 17 '16 at 11:00
  • The difference is that `GET` request doesn't have (at least *shouldn't have*) a request payload. I understand the OP is receiving the `rawData` in the payload (body) of a `PUT` request. – cassiomolin Oct 17 '16 at 13:12