Use of Optional comes from the DropWizard configuration, this is not bespoke code. DropWizard masks the stack trace and instead gives that error message, but I've managed to extract it:
java.lang.RuntimeException: io.dropwizard.configuration.ConfigurationParsingException: /home/developer/projects/employee-service/employee-service-parent/employee-service/target/test-classes/config.yml has an error: * Failed to parse configuration at: metrics.reporters; Must call method with a container type (got [reference type, class java.util.Optional<io.dropwizard.util.Duration<[simple type, class io.dropwizard.util.Duration]>]) at [Source: N/A; line: -1, column: -1] (through reference chain: coop.employee.EmployeeServiceConfiguration["metrics"]->io.dropwizard.metrics.MetricsFactory["reporters"]) at com.google.common.base.Throwables.propagate(Throwables.java:160) at io.dropwizard.testing.DropwizardTestSupport.startIfRequired(DropwizardTestSupport.java:196) at io.dropwizard.testing.DropwizardTestSupport.before(DropwizardTestSupport.java:112) at io.dropwizard.testing.junit.DropwizardAppRule.before(DropwizardAppRule.java:128) at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:46) at org.junit.rules.RunRules.evaluate(RunRules.java:20) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268) at org.junit.runners.ParentRunner.run(ParentRunner.java:363) at org.junit.runner.JUnitCore.run(JUnitCore.java:137) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:117) at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42) at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:262) at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:84) Caused by: io.dropwizard.configuration.ConfigurationParsingException: /home/developer/projects/employee-service/employee-service-parent/employee-service/target/test-classes/config.yml has an error: * Failed to parse configuration at: metrics.reporters; Must call method with a container type (got [reference type, class java.util.Optional<io.dropwizard.util.Duration<[simple type, class io.dropwizard.util.Duration]>]) at [Source: N/A; line: -1, column: -1] (through reference chain: coop.employee.EmployeeServiceConfiguration["metrics"]->io.dropwizard.metrics.MetricsFactory["reporters"]) at io.dropwizard.configuration.ConfigurationParsingException$Builder.build(ConfigurationParsingException.java:276) at io.dropwizard.configuration.YamlConfigurationFactory.build(YamlConfigurationFactory.java:152) at io.dropwizard.configuration.YamlConfigurationFactory.build(YamlConfigurationFactory.java:87) at io.dropwizard.cli.ConfiguredCommand.parseConfiguration(ConfiguredCommand.java:124) at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:72) at io.dropwizard.testing.DropwizardTestSupport.startIfRequired(DropwizardTestSupport.java:194) ... 18 more Caused by: com.fasterxml.jackson.databind.JsonMappingException: Must call method with a container type (got [reference type, class java.util.Optional<io.dropwizard.util.Duration<[simple type, class io.dropwizard.util.Duration]>]) at [Source: N/A; line: -1, column: -1] (through reference chain: coop.employee.EmployeeServiceConfiguration["metrics"]->io.dropwizard.metrics.MetricsFactory["reporters"]) at com.fasterxml.jackson.databind.JsonMappingException.from(JsonMappingException.java:290) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:269) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:244) at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:142) at com.fasterxml.jackson.databind.DeserializationContext.findContextualValueDeserializer(DeserializationContext.java:444) at com.fasterxml.jackson.databind.jsontype.impl.TypeDeserializerBase._findDeserializer(TypeDeserializerBase.java:183) at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer._deserializeTypedForId(AsPropertyTypeDeserializer.java:106) at com.fasterxml.jackson.databind.jsontype.impl.AsPropertyTypeDeserializer.deserializeTypedFromObject(AsPropertyTypeDeserializer.java:91) at com.fasterxml.jackson.databind.deser.AbstractDeserializer.deserializeWithType(AbstractDeserializer.java:142) at com.fasterxml.jackson.datatype.guava.deser.GuavaImmutableCollectionDeserializer._deserializeContents(GuavaImmutableCollectionDeserializer.java:44) at com.fasterxml.jackson.datatype.guava.deser.GuavaImmutableCollectionDeserializer._deserializeContents(GuavaImmutableCollectionDeserializer.java:14) at com.fasterxml.jackson.datatype.guava.deser.GuavaCollectionDeserializer.deserialize(GuavaCollectionDeserializer.java:103) at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95) at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:156) at com.fasterxml.jackson.databind.deser.SettableBeanProperty.deserialize(SettableBeanProperty.java:490) at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:95) at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:224) at com.fasterxml.jackson.module.afterburner.deser.SuperSonicBeanDeserializer.deserialize(SuperSonicBeanDeserializer.java:152) at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:3779) at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2050) at io.dropwizard.configuration.YamlConfigurationFactory.build(YamlConfigurationFactory.java:123) ... 22 more Caused by: java.lang.IllegalArgumentException: Must call method with a container type (got [reference type, class java.util.Optional<io.dropwizard.util.Duration<[simple type, class io.dropwizard.util.Duration]>]) at com.fasterxml.jackson.module.jaxb.JaxbAnnotationIntrospector.findPropertyContentTypeResolver(JaxbAnnotationIntrospector.java:567) at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.findPropertyContentTypeResolver(AnnotationIntrospectorPair.java:233) at com.fasterxml.jackson.databind.introspect.AnnotationIntrospectorPair.findPropertyContentTypeResolver(AnnotationIntrospectorPair.java:233) at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.findPropertyContentTypeDeserializer(BasicDeserializerFactory.java:1516) at com.fasterxml.jackson.databind.deser.BasicDeserializerFactory.resolveType(BasicDeserializerFactory.java:1886) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.constructSettableProperty(BeanDeserializerFactory.java:717) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:504) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:228) at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:143) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:406) at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:352) at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:264) ... 42 more It does look like a Jackson issue, but I thought someone else might have experienced it in this scenario. I'll try to get a test for Jackson, but at the moment I've just parked the upgrade to get on with something else. On Thursday, 29 September 2016 15:44:25 UTC+1, Tatu Saloranta wrote: > > You'd need to include the stack trace: just generally indicating it comes > from JaxbAnnotationIntrospector does not help a lot unfortunately. > Exception does not look familiar. > Also, if possible, it'd be great to have a self-contained test for > Jackson, since this sounds like either a Jackson bug (more likely), or > problem with DW configuration setup (less likely). > > -+ Tatu +- > > ps. Not sure why `Optional` is used in configuration, seems like an > anti-pattern to me. But perhaps that's what DropWizard configuration uses. > If not, I'd just get rid of that to simplify handling, remove one possible > source of issues. > > > On Thu, Sep 29, 2016 at 3:14 AM, Adrian Riley <[email protected] > <javascript:>> wrote: > >> Upgraded Jackson to 2.8.3, where the code around here has changed, but >> still got the same error. >> >> -- >> You received this message because you are subscribed to the Google Groups >> "dropwizard-user" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected] <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- You received this message because you are subscribed to the Google Groups "dropwizard-user" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
