codahale/dropwizard — Issue #39: New config parser fails with nested types
Author: ieure
Created: 2012-02-27 18:47:48+00:00
State: open

DW >= 0.2.0 breaks config parsing. I have the following configuration classes for my (Scala) service:

class CryptoConfiguration extends Configuration {
var keyStore = "key.store"
var keyPass = ""
var algo = ""
var keySize: Int = 0
}

class ExternalServiceConfiguration extends Configuration {
var api: URL = new URL("http://wrongo:1234")
var user = ""
var pass = ""
}

class ServiceConfiguration extends Configuration {
var database = new DatabaseConfiguration()
var rabbit = new RabbitConfiguration()
var cachet = new CachetConfiguration()
var s3 = new S3Configuration()
var crypto = new CryptoConfiguration()
var api = new URL("http://fixme")
}

And here's the config.yml:

http:
port: 12004
adminPort: 12005
maxIdleTime: 30s

requestLog:
enabled: true

rabbit:
host: localhost
vhost: /local/myservice
username: myservice
password: myservice

database:
url: jdbc:postgresql://localhost/myservice
username: myservice
password: myservice

externalservice:
api: https://externalservice.com
user: elided
pass: elided

# Logging settings.
logging:
level: DEBUG
console:
enabled: true
threshold: DEBUG

syslog:
enabled: false

loggers:
org.apache.http.wire: WARN
org.eclipse.jetty.http.HttpParser: WARN
org.apache.http.headers: DEBUG
org.eclipse.jetty.server.AbstractHttpConnection: WARN
org.eclipse.jetty.server.handler.ContextHandler: WARN
org.eclipse.jetty.io.nio.ChannelEndPoint: WARN
org.eclipse.jetty.servlet.ServletHandler: WARN
org.eclipse.jetty.server.AbstractConnector: WARN
org.eclipse.jetty.util.component.AbstractLifeCycle: WARN
org.eclipse.jetty.util.component.Container: WARN

file:
enabled: true
threshold: ALL
filenamePattern: ./logs/myservice.log

s3:
bucket: myservice-dev
key: elidedd
secret: elided

crypto:
keyStore: key.store
keyPass: elided
algo: Blowfish
keySize: 256

api: http://randomhost

When I start the service, it dies with:

Exception in thread "main" org.codehaus.jackson.map.exc.UnrecognizedPropertyException: Unrecognized field "rabbit" (Class com.simple.clownshoes.config.ServiceConfiguration), not marked as ignorable
at [Source: N/A; line: -1, column: -1] (through reference chain: com.simple.clownshoes.config.ServiceConfiguration["rabbit"])
at org.codehaus.jackson.map.exc.UnrecognizedPropertyException.from(UnrecognizedPropertyException.java:53)
at org.codehaus.jackson.map.deser.StdDeserializationContext.unknownFieldException(StdDeserializationContext.java:267)
at org.codehaus.jackson.map.deser.std.StdDeserializer.reportUnknownProperty(StdDeserializer.java:672)
at org.codehaus.jackson.map.deser.std.StdDeserializer.handleUnknownProperty(StdDeserializer.java:658)
at org.codehaus.jackson.map.deser.BeanDeserializer.handleUnknownProperty(BeanDeserializer.java:1361)
at org.codehaus.jackson.map.deser.BeanDeserializer._handleUnknown(BeanDeserializer.java:725)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:703)
at org.codehaus.jackson.map.deser.BeanDeserializer.deserialize(BeanDeserializer.java:580)
at org.codehaus.jackson.map.ObjectMapper._readValue(ObjectMapper.java:2704)
at org.codehaus.jackson.map.ObjectMapper.readValue(ObjectMapper.java:1999)
at com.yammer.dropwizard.json.Json.readYamlValue(Json.java:508)
at com.yammer.dropwizard.config.ConfigurationFactory.parse(ConfigurationFactory.java:43)
at com.yammer.dropwizard.config.ConfigurationFactory.build(ConfigurationFactory.java:36)
at com.yammer.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:69)
at com.yammer.dropwizard.cli.Command.run(Command.java:112)
at com.yammer.dropwizard.AbstractService.run(AbstractService.java:178)
at com.yammer.dropwizard.ScalaService.main(ScalaService.scala:13)

Everything works fine on 0.1.3.