How can the following produce this error when they have different URLs ?
@Path("/job/{empId}/empProfile")
public EmpProfileResource delegateToEventProfileResource() {
EmpProfileResource resource = new EmpProfileResource();
locator.inject(resource);
return resource;
}
@Path("/job/{empId}/empTask")
public EmpTaskResource getClientLevelAttendees(@PathParam("clientId") long clientId){
EmpTaskResource resource = new EmpTaskResource (empId);
locator.inject(resource);
return resource;
}
@Path("/")
public class EmpTaskResource{
}
@Path("/")
public class EmpProfileResource{
}
Yes, they both are GET and produce the same, so ?
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
Error:
[[FATAL] A resource model has ambiguous (sub-)resource method for HTTP method GET and input mime-types as defined by"@Consumes" and "@Produces" annotations at Java methods public javax.ws.rs.core.Response com.EmpTaskResource.getEmpTasks(java.time.LocalDate,java.time.LocalDate,java.lang.String) and public javax.ws.rs.core.Response com.EmpProfileResource.getEmpProfiles(long,java.lang.String) at matching regular expression /. These two methods produces and consumes exactly the same mime-types and therefore their invocation as a resource methods will always fail.;
I had the same error. Most people resolved the error by changing their @Path annotations because they where ubiquitous. In my case something different happened. I modified a package from aaa to bbb for example. For some reason in the artifact deployed to the server there where both the aaa and bbb packages, so the resources where duplicated and the server raised the exception. I had to clear the previous deployed artifact and deploy the new. Someone may check this case also where the error appears. Of course at the end of the day the reason is again a path ubiquity. I am suffering with the same problem i have also updated a version check but its give me a same problem may jersey frame works is not supporting this
Remove the @Path("/")
from the sub-resource classes. Sub-resource classes don't need them. And if they have them, they get added as root resource classes, if you are scanning for @Path
annotated classes. And this is the problem. You haven't show the methods of the sub-resource classes, but because the have the same root path, I would imagine that the problem is caused by some overlapping methods. So just remove the @Path("/")
on sub-resource classes, and you should be OK.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With