Javax Constraint Validation fails for Dropwizard 7

345 views
Skip to first unread message

Gagan B Mishra

unread,
Mar 10, 2015, 7:10:18 AM3/10/15
to dropwiz...@googlegroups.com
Hello,

I am using dropwizard 7 with guice. But there seems to be a bug in dropWizard due to which my application doesn't run. 
I found out that the HttpClientConfiguration is having this constraint :

@NotNull
    private Optional<String> userAgent = Optional.absent();

I initialize my configuration as :

@Valid
  @NotNull
  private JerseyClientConfiguration clientConfiguration = new JerseyClientConfiguration();


As bootstrap adds OptionalValidatedValueUnwrapper during setup, this results in ConstraintViolationException:

javax.validation.UnexpectedTypeException: HV000186: The constraint of type 'javax.validation.constraints.NotNull' defined on 'clientConfiguration.userAgent' has multiple matching constraint validators which is due to an additional value handler of type 'io.dropwizard.validation.valuehandling.OptionalValidatedValueUnwrapper'. It is unclear which value needs validating. Clarify configuration via @UnwrapValidatedValue.



at org
.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.verifyResolveWasUnique(ConstraintValidatorManager.java:243)

at org
.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.findMatchingValidatorClass(ConstraintValidatorManager.java:222)

at org
.hibernate.validator.internal.engine.constraintvalidation.ConstraintValidatorManager.getInitializedValidator(ConstraintValidatorManager.java:101)

at org
.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:129)

at org
.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:84)

at org
.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:544)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:479)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:443)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:395)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:725)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:611)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:404)

at org
.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:194)

at io
.dropwizard.configuration.ConfigurationFactory.validate(ConfigurationFactory.java:237)

at io
.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:126)

at io
.dropwizard.configuration.ConfigurationFactory.build(ConfigurationFactory.java:77)

at io
.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:114)

at io
.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:63)

at io
.dropwizard.cli.Cli.run(Cli.java:70)

at io
.dropwizard.Application.run(Application.java:72)


Any help on how to get this thing moving ?

Thanks

Rajnish Kumar

unread,
Jan 19, 2016, 1:42:00 AM1/19/16
to dropwizard-user
Hi Gagan,

were you able to fix this, I am also facing the same issue.
Reply all
Reply to author
Forward
0 new messages