I'm facing a tricky behavior from my REST resource.
The exposed method is expecting a complex json object :

```
@Path(RestURIConstant.NOTIFICATION_ROOT_URI)
@Component
@Scope("request")
public class NotificationResource implements RestURIConstant {

    /** Notification service. */
    @Autowired
    private INotificationService notificationService;

    @Path(RestURIConstant.COMPLEMENT_URI)
    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    @Produces(MediaType.APPLICATION_JSON)
    public Response processNotification(final EventDTO event)
        throws BusinessException, TechnicalException {
        checkParameters(event);

        notificationService.processEvent(event);

        return Response.ok().build();
    }
}

```

EventDTO has two enum fields : notificationType and eventType :

```
public class EventDTO {
    private ENotificationType notificationType;    
    private EEventType eventType;
    private String eventDate;
    private String userName;

    //... getters, setters
}

```

What I want is to map exception from any kind of data validation error to get at the end a json response with an error code and error message. And after following [jax-rs jersey: Exception Mapping for Enum bound FormParam](https://stackoverflow.com/questions/17531920/jax-rs-jersey-exception-mapping-for-enum-bound-formparam) :

So for the ENoticationType I wrote :

```
public enum ENotificationEventType {
    RULE,
    ALARM,
    ACK,
    INFO;

    @JsonCreator
    public static ENotificationEventType fromString(final String typeCode)
        throws BusinessException {
        if (typeCode == null) {
            throw new BusinessException(ValidationCode.VALUE_REQUIRED, "type");
        }
        try {
            return valueOf(typeCode);
        } catch (final IllegalArgumentException iae) {
            throw new BusinessException(ValidationCode.UNSUPPORTED_VALUE, "type", typeCode, Arrays.toString(values()));
        }
    }
}

```

And for the Mapper I wrote :

```
@Provider
@Singleton
public class BusinessExceptionMapper implements ExceptionMapper<BusinessException> {

    @Override
    public Response toResponse(final BusinessException exception) {

        Status status = Status.INTERNAL_SERVER_ERROR;

        // If a validationCode error = unsupported version => CODE 410
        if (exception.getErrorCode().equals(ValidationCode.UNSUPPORTED_API_VERSION)) {
            status = Status.GONE;
        } else if (exception.getErrorCode().getClass().isAssignableFrom(ValidationCode.class)) {
            // If a validationCode error then BAD_REQUEST (400) HTTP
            status = Status.BAD_REQUEST;
        } else if (exception.getErrorCode().getClass().isAssignableFrom(NotFoundCode.class)) { // CODE 404
            status = Status.NOT_FOUND;
        } else if (exception.getErrorCode().getClass().isAssignableFrom(SecurityCode.class)) { // CODE 401
            status = Status.UNAUTHORIZED;
        } else if (exception.getErrorCode().getClass().isAssignableFrom(AdminSecurityCode.class)) { // CODE 401
            status = Status.UNAUTHORIZED;
        }

        return Response.status(status).type(MediaType.APPLICATION_JSON)
            .entity(ErrorMessageHelper.createErrorMessageHelper(
                    exception.getErrorCode(), exception.getMessage()))
                    .build();
}

```

And my application-context contains `<context:component-scan base-package=" com.technicolor.hovis.backend.rest, com.technicolor.hovis.admin.rest" />`

I already read several answers to questions relative to Exception mapping in jersey but in my case, it's not that the mapping is not recognized but that it's not applied in all cases :

1. the exceptions thrown by checkParameters are mapped and the result is as expected
2. but if an invalid enum is sent, the `@JsonCreator` method is called, throw the same type of exception but this one is not mapped as expected.

So The response looks like : 

```html
 <data contentType="text/plain;charset=UTF-8" contentLength="176">
      <![CDATA[Unsupported type value : 'ALARN'. Expected values are [RULE, ALARM, ACK, INFO] (through reference chain: EventDTO["type"])]]>
</data>
```

And not the expected :

```
{
   "code": 6,
   "message": "Unsupported type value : 'ALARN'. Expected values are [RULE, ALARM, ACK, INFO]"
}

```

Any idea ?

Cyril