@GET
@Path("/rest/balancequery")
@Produces(MediaType.APPLICATION_JSON)
public XXXPojo balanceQuery(@Context UriInfo ui) {
XXXPojo p = new XXXPojo();
Boolean fail = this.checkAuthority(ui);
if(fail) {
throw new WebApplicationException(Response.Status.FORBIDDEN);
}
else {
p = getPojo();
}
return p
}
WebAppliactionException
is described as none-detectable exception, and should return 403. However, the console output does show the trace of exception (I think this means it is detectable), and the client receives 200 as code. It is also mentioned in answer "should not return entity". It is impossible for a jersey just return 403 but not a bean when nothing goes wrong. I cannot use glassfish jersey. jdk 1.7 thanks.
<!-- jersey -->
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-server</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.19</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>1.19</version>
<scope>test</scope>
</dependency>
<!-- Jetty -->
<dependency>
<groupId>org.eclipse.jetty.aggregate</groupId>
<artifactId>jetty-all-server</artifactId>
<version>8.1.16.v20140903</version>
</dependency>