users@jersey.java.net

[Jersey] exception mapping not working

From: sstaley <scottbodhi_at_gmail.com>
Date: Fri, 27 Jan 2012 15:31:53 -0800 (PST)

Hello,
I'm having a problem with mapping an exception using jersey 1.3 and embedded
jetty 6.1. Jersey is working great in all other respects in my application.
I have a resource class which contains the following:

@Path("/pinvalidation/{transactionId}/{pin}")
@Provider
public class PinValidationResource extends MHCResource implements
        ExceptionMapper<java.lang.IllegalArgumentException>
{

....

    @Override
    public Response toResponse(IllegalArgumentException arg0) {
        Log.info("*********************");
        return Response.ok().entity(
                new
MHCResponse.Builder(MHCResponseResultCode.RESULT_CLOSE_SESSION).build()
                ).build();
                
    }

And from a method which handles POST requests, I do some validation and
throw a new IllegalArgumentException. But, code in toResponse isn't being
invoked and the exception makes it's way to the container instead. I have
found a Jersey exception:

<record>
  <date>2012-01-27T15:12:45</date>
  <millis>1327705965987</millis>
  <sequence>11</sequence>
  <logger>com.sun.jersey.spi.container.ContainerResponse</logger>
  <level>SEVERE</level>
  <class>com.sun.jersey.spi.container.ContainerResponse</class>
  <method>mapMappableContainerException</method>
  <thread>11</thread>
  <message>The RuntimeException could not be mapped to a response,
re-throwing to the HTTP container</message>
  <exception>
    <message>java.lang.IllegalArgumentException: No enum const class
com.boku.mhc.services.PinType.uth</message>

Any ideas?


--
View this message in context: http://jersey.576304.n2.nabble.com/exception-mapping-not-working-tp7231462p7231462.html
Sent from the Jersey mailing list archive at Nabble.com.