title: javax.ws.rs.core.Response.ResponseBuilder.entity returns 500
body: <p>I'm using ResponseBuilder to build my response for my Jersey webservice method</p>
  
  <p><a href="http://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Response.ResponseBuilder.html#entity%28java.lang.Object%29" rel="nofollow">http://docs.oracle.com/javaee/7/api/javax/ws/rs/core/Response.ResponseBuilder.html#entity%28java.lang.Object%29</a></p>
  
  <p>It's called this way:</p>
  
  <pre><code>try {
      //...
  }
  catch (Exception ex) {
      Response.serverError().entity(ex).build();
      //...
  }
  </code></pre>
  
  <p>The webservice method is supposed to return MediaType.APPLICATION_JSON, however, it returns a HTML page showing 500: Internal Server Error.</p>
  
  <p>When using Response.ok(variable) for variable of any data type except those inherited from class Exception, everything goes fine with a proper JSON returned.</p>
  
  <p>What happened when I pass 'ex' as parameter to method 'entity'?</p>