I'm using Jakarta REST API in Jakarta EE 10 and I noticed that if I try to parse an empty @PathParam
in a GET method it works only if there are no other REST methods in the same class.
I have the following class, where the getCustomer()
method takes the request no matter if it's empty or not. I omitted the method's body for brevity but basically it just returns a List
of RestCustomer
containing all of them if the request is empty or just the ones that match the request if it's not empty.
@Path("/customer/")
public class CustomerResource {
@GET @Produces("text/xml")
@Path("{query: .*}/")
public List<RestCustomer> getCustomer(@PathParam("query") String query) {
// method body
}
}
So far it works good. You can send the request http://example.com/resources/customer/
or http://example.com/resource/customer/5
and it will work both ways.
But once I add other REST methods such as PUT, POST or DELETE, the getCustomer()
method just stops working if the request is empty and it throws an HTTP Status 405 - Method not allowed
error. Why is this happening? Is there any way to solve it?