0

I am far from sure where to even begin with this... I have created 2 endpoints using Jersey and one of them works as expected while the other one gives a 404 response. However if I remove the query parameter then it works.

@GET
@Path("/note")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets a saved note", notes = "Gets a saved note from the database")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK,
                                    message = "The saved note was successfully gotten",
                                    response = Note.class), @ApiResponse(code = HttpServletResponse.SC_NOT_FOUND,
                                                                         message = "Could not find the note",
                                                                         response = ErrorMessage.class)})
Response getNote(
        @ApiParam(value = "The ID of the note to get", required = true) @QueryParam("noteID") String noteID) throws
        Exception;

@GET
@Path("/note/root")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Gets all root elements", notes = "Gets all elements that do not have a parent relation")
@ApiResponses(value = {@ApiResponse(code = HttpServletResponse.SC_OK,
                                    message = "All root notes",
                                    response = Note.class)})
Response getRootNotes() throws Exception;

That is the interface I use. getNote endpoint gives a 404 and the getRootNotes gives the response I expect.

@Component
public class NotesBean implements Notes
{

@Override
public Response getNote(
        @ApiParam(value = "The ID of the note to get", required = true) @QueryParam("note") String noteID) throws
        Exception
{
    return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).build();
}

@Override
public Response getRootNotes() throws Exception
{
    return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).build();
}
}

The implementation is trivial to say the least

If it is of any use I am using tomcat9 to host it.

Also, in my web.xml I believe I have it properly mapped:

<servlet-mapping>
    <servlet-name>jersey</servlet-name>
    <url-pattern>/api/*</url-pattern>
</servlet-mapping>

Anyone have any idea of what might be wrong?

munHunger
  • 2,572
  • 5
  • 34
  • 63

0 Answers0