question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Application start fails due to "java.lang.ClassCastException: io.dropwizard.util.Size cannot be cast to java.util.Optional"

See original GitHub issue

Hi!

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:closed
  • Created 6 years ago
  • Comments:15 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
maksymgendincommented, May 15, 2017

The only workaround that I know is setting the log4j2 log level for Hibernate validator higher than TRACE.

1reaction
nickbabcockcommented, Jun 5, 2017

Reported upstream as HV-1352. Dropwizard users can use the provided workarounds until fixed upstream.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found