Application start fails due to "java.lang.ClassCastException: io.dropwizard.util.Size cannot be cast to java.util.Optional"
See original GitHub issueHi!
Has anyone seen this error already? I am using Dropwizard 1.1.0.
It happens while validating some fields (e.g. inputBufferSize
field) in io.dropwizard.jetty.HttpConnectorFactory
even if I do not specify a server
block in my configuration YAML, so the default values are used.
java.lang.ClassCastException: io.dropwizard.util.Size cannot be cast to java.util.Optional
at org.hibernate.validator.internal.engine.valuehandling.OptionalValueUnwrapper.handleValidatedValue(OptionalValueUnwrapper.java:20)
at org.hibernate.validator.internal.engine.ValueContext.getCurrentValidatedValue(ValueContext.java:121)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:110)
at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:87)
at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:73)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateMetaConstraint(ValidatorImpl.java:620)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:583)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForSingleDefaultGroupElement(ValidatorImpl.java:527)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:495)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:460)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:410)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:761)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:684)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:419)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraint(ValidatorImpl.java:761)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateCascadedConstraints(ValidatorImpl.java:684)
at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:419)
at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:207)
at io.dropwizard.configuration.BaseConfigurationFactory.validate(BaseConfigurationFactory.java:237)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:129)
at io.dropwizard.configuration.BaseConfigurationFactory.build(BaseConfigurationFactory.java:92)
at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:124)
at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72)
at io.dropwizard.cli.Cli.run(Cli.java:74)
at io.dropwizard.Application.run(Application.java:89)
The same also occurs sometimes for io.dropwizard.util.Duration
(e.g. idleTimeout
field).
Best regards Maksym
Issue Analytics
- State:
- Created 6 years ago
- Comments:15 (6 by maintainers)
Top Results From Across the Web
java.lang.ClassCastException: io.dropwizard.jetty ...
java.lang.ClassCastException: io.dropwizard.jetty.BiDiGzipHandler$WrappedServletRequest cannot be cast to org.eclipse.jetty.server.Request.
Read more >java.util.Optional.ofNullable java code examples - Tabnine
private Double calculateAverageGrade(Map<String, List<Integer>> gradesList, String studentName) throws Exception { return Optional.
Read more >ClassCastException "cannot be cast to class java.lang ...
The exception occurs with all java.util.TreeMap methods which use cast to Comparable in their implementation. Such as put , contains and getEntry ....
Read more >Dropwizard Validation
Dropwizard comes with a host of validation tools out of the box to allow endpoints to return meaningful error messages when constraints are...
Read more >Upgrade guide - DataStax Java Driver
Runtime requirements. The driver now requires Java 8 or above. It does not depend on Guava anymore (we still use it internally but...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The only workaround that I know is setting the log4j2 log level for Hibernate validator higher than TRACE.
Reported upstream as HV-1352. Dropwizard users can use the provided workarounds until fixed upstream.