I have created an app implementing REST services locally using:
Eclipse Indigo Jersey 2.4 Tomcat 7.0.47
When running locally using Eclipse, the services work
Apparently the main causes of failure is because there is duplicate reference in the services path, this is multiple path ("/"), as well as the existence of resources without defined path or such resource classes do not count Less with some defined (@GET, @POST, @UPDATE, @DELETE, ...) method.
In order to solve this, a path (not duplicated) must be indicated for each resource and at least in each resource there must be one or more published methods, the lack of these methods in different versions of jersey could cause this exception.
Example:
package com.contpaq.tech.service.resources;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
@Path("/")
public class RootSrv {
@GET
@Produces(MediaType.TEXT_PLAIN + ";charset=utf-8")
public Response getVersion() {
return Response.ok().entity("NodeServer Versión 0.6.69").build();
}
}
One possible cause is that you have two or more applicable mappings for that URL call.
For example:
@Path("/{myParam}")
And somewhere else:
@Path("/{differentParam}")
Now Jersey have no way of telling what method is actually supposed to be called and gives this error.
The above exception might be a consequence exception when Jersey cannot inject some user type into e.g. @QueryParam
/@PathParam
. E.g. you haven't registered your ParamConverterProvider
. Look above in the logs, for the first exception trace.
I resolved my case with:
@Component
public static class JerseyConfig extends ResourceConfig {
public JerseyConfig() {
this.register(LocalDateParamProvider.class);
}
}
(I use Spring.) When I inserted the above register()
call, the exception has gone.