How can the following produce this error when they have different URLs ?
@Path(\"/job/{empId}/empProfile\")
public EmpProfileResource delegateToEventProfileR
This error arises if we have written @PathParam instead of @Path in our service class or where ever we are defining the path for same.
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.
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
I had this error two times now. Both were different:
First time I had at the following above GET and POST Methods etc.
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
But I didn't have it infront of the class. So if you have different class-ressources like:
@Path("/users")
public Class User{}
and
@Path("/lists")
public Class List{}
Then BOTH of them need the
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
infront of them:
@Path("/users")
@Produces({MediaType.APPLICATION_JSON})
@Consumes({MediaType.APPLICATION_JSON})
public Class User{}
Second time I moved a resource (endpoint) class from one folder to a different one (via refactor from Intellij) and apparently the IDE doesn't recognize this. Then the exact problem occurs which Panagiotis Piperopoulos already described.
To fix it I did the following:
Go to the folder where you project is located (<working_directory>
). There you will find a folder called target (<working_directory>\target
)
There was in my case 1: a war file. Delete that.
2: A folder which contains the meta-inf and web-inf and index.html. The name is probably your module name (in IntelliJ: File -> Project Structure -> Module). Rename that folder to something like <old_name>_old
If you re-compile your code then the folder and a new .war file should appear.