Reputation: 211
I have a Jersey REST service that invokes several other REST services and combines their returns to form a new return. My unit tests pass, but in integration I get a 400 Bad Request and can not figure out who is returning that. Does Jersey parse input and return a 400?
@GET
@Path("/existing/{name}")
@Produces( MediaType.APPLICATION_JSON )
def namedFriction( @PathParam("name") String name, @Context HttpServletRequest request ) {
Cookie ssoToken = HTTPUtils.getSSOCookie(request)
def results = frictionBuilderService.checkCatalogForName(name, ssoToken)
def requestUrl = HttpUtil.getBaseContextUrl( request )
if ( results != null ) return frictionBuilderService.formatFriction(results, requestUrl)
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build() )
}
Upvotes: 4
Views: 10678
Reputation: 211
After 5 hours, I found the answer. I was looking in the wrong place. Turns out, Runtime exceptions are turned into 400 Bad Request by Jersey response handler. I was focused on other services when the issue was my own service throwing an IllegalArgumentException from a loop.
Place a try catch (Exception e) around your service impl and find the issue quickly. Jersey strips the stack trace when returning this error and it may not be from a remote service, might be your own code.
Placed here for posterity for any others so afflicted. I did not know where else to note this.
Upvotes: 10