protected void writeFailure(HttpRequest request, HttpResponse response, Response jaxrsResponse) {
    response.reset();
    try {
      writeJaxrsResponse(request, response, jaxrsResponse);
    } catch (WebApplicationException ex) {
      if (response.isCommitted())
        throw new UnhandledException("Request was committed couldn't handle exception", ex);
      // don't think I want to call writeJaxrsResponse infinately! so we'll just write the status
      response.reset();
      response.setStatus(ex.getResponse().getStatus());

    } catch (Exception e1) {
      throw new UnhandledException(e1); // we're screwed, can't handle the exception
    }
  }