The Jersey-built ValidationExceptionMapper is registered through the ValidationFeature. Perhaps replacing the Jersey ValidationFeature with your own version might help. This can be done as follows.
First off, automatically detect ValidationFeature
property(ServerProperties.BV_FEATURE_DISABLE, true);
The next step is to register a clone of the Jersey validation function.
public static class ValidationFeatureClone implements Feature { @Override public boolean configure(FeatureContext context) { context.register(new ValidationBinder()); context.register(NewValidationExceptionMapper.class); context.register(ValidationErrorMessageBodyWriter.class); return true; } }
In the clone, you must specify your new ExceptionMapper.
Finally register your new feature
register(ValidationFeatureClone.class)
UPDATE:
Starting with version 2.20, the default ValidationExceptionMapper can be overwritten using the HK2 binding, as shown below.
register(new AbstractBinder() { @Override protected void configure() { bind(NewValidationExceptionMapper.class).to(ExceptionMapper.class) .in(Singleton.class).ranked(10ββ); } });
Justin jose
source share