[JAX-RS] ExceptionMapper example (Maven + Jersey + Glassfish)

Create a new Maven project (Web app archetype) in eclipse and add the dependencies on jersey. Also you will need Glassfish server.
1. pom.xml

2. Main Application

3. An example service

4. The Exception Mapping class. Here we’re mapping the IllegalArgumentException to a BAD_REQUEST

 

Leave a Reply

Your email address will not be published. Required fields are marked *