Just one thing to add to the already existing responses. What Jersey is doing is the correct behavior as for the spec:
3.3.3 Return Type
Resource methods MAY return void, Response, GenericEntity, or another Java type, these return types are mapped to a response entity body as follows:
void Results in an empty entity body with a 204 status code.
Response Results in an entity body mapped from the entity property of the Response with the status code specified by the status property of the Response. A null return value results in a 204 status code.
If the status property of the Response is not set: a 200 status code is used for a non-null entity property and a 204 status code is used if the entity property is null.
GenericEntity Results in an entity body mapped from the Entity property of the GenericEntity. If the return value is not null a 200 status code is used, a null return value results in a 204 status code.
Other Results in an entity body mapped from the class of the returned instance. If the return value is not null a 200 status code is used, a null return value results in a 204 status code.
[...]
And since you are using an exception, the following section applies (emphasis mine):
3.3.4 Exceptions
A resource method, sub-resource method or sub-resource locator may throw any checked or unchecked
exception. An implementation MUST catch all exceptions and process them as follows:
- Instances of WebApplicationException MUST be mapped to a response as follows. If the
response property of the exception does not contain an entity and an exception mapping provider
(see section 4.4) is available for WebApplicationException an implementation MUST use the
provider to create a new Response instance, otherwise the response property is used directly. The
resulting Response instance is then processed according to section 3.3.3.
[...]
So you should either return null, void or build a 204 response. You throw exceptions only if it's an exceptional case in your application and throwing the exception makes this clear.