I'm using jersey 1.8 from the jersey bundle and running on glassfish 3.1. I'm writing a REST web service and all has been peachy, until I need to send a specific response code. Every time I try to get a ResponseBuilder object I get a very generic jersey exception. Here's my code:
The method errors out on line 20. Note I know that this code doesn't do anything useful. I'm attempting to return a 403 response with a custom header. In my testing I deliberately call the method with parameters that will cause a ForbiddenException (a custom exception) to be thrown. Here is the error I see when I attempt to execute line 20 above:
Prior to this the method's return type was JSONObject and I wasn't attempting to modify the response in any way and life was hunky-dory. Does anyone have any ideas what I could do to make this work? I've been at it for hours.
posted 4 years ago
Well, I found something that worked. I did not find any documentation that said to do it this way, but it has the virtue of working: