Exceptions Example

This example demonstrates how to throw and map exceptions using ExceptionMapper in Jersey resource classes.

Contents

The example consists of just one Jersey resource:

com.sun.jersey.samples.exceptions.MyResource
that produces a textual response to an HTTP GET.

The mapping of the URI path space is presented in the following table:

URI path Resource class HTTP methods
/myresource MyResource GET
/myresource/runtime MyResource GET
/myresource/checked/ioexception MyResource GET
/myresource/checked/mymappedexception MyResource GET
/myresource/checked/mymappedruntimeexception MyResource GET
/myresource/checked/mymappedthrowingexception MyResource GET
/myresource/webapplicationexception/{status} MyResource GET

Running the Example

Run the example as follows:

run

mvn clean compile exec:java

From a web browser, visit:

http://localhost:9998/myresource