portable perspectives

a blog about programming, life, universe and everything

method not recognized error with Jersey

Jersey is a neat small framework implementing JSR311, the restful webservices for java spec. I'm posting this article just so that someone may avoid hitting the same problem I hit, wasting fifteen minutes trying to understand what was happening.

This error:

/some/path.foo: javax.servlet.UnavailableException: 
com.sun.jersey.api.container.ContainerException: 

Method, public theMethod(java.lang.String), 
annotated with GET of resource, class TheClass, 

is not recognized as valid Java method annotated with @HttpMethod.

Now, consider that @HttpMethod is defined by the @GET & co annotations, so what is it complaining about?

What this UnavailableException/ContainerException actually means is

you mismatched a method annotated with @GET with arguments annotated as @FormParam, whereas you should have used @QueryParam

I am led to believe that also mixing @POST and @QueryParam would lead to the same ContainerException but I did not check. I still like jersey though, although I guess the diagnostics could be improved a bit :)

AddThis Social Bookmark Button

Sorry, comments are closed for this article.