Override configuration settings by passing special Java system properties

2,822 views
Skip to first unread message

James Wyatt

unread,
May 28, 2013, 11:14:17 PM5/28/13
to dropwiz...@googlegroups.com
Should this work?:

      java -Xmx384m -Xss512k -XX:+UseCompressedOops -Ddw.http.port=36227 -Ddw.http.adminPort=36227 -jar dropwizard-example/target/dropwizard-example-0.7.0-SNAPSHOT.jar server dropwizard-example/example.yml

as documented here: http://dropwizard.codahale.com/manual/core/#configuration


I am getting:

     Exception in thread "main" com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException: Unrecognized field "http" (class com.example.helloworld.HelloWorldConfiguration), not marked as ignorable (5 known properties: , "server", "template", "database", "defaultName", "logging"])


I'm testing out Heroku and I need to be able to override the configured http ports with environment variables they give me. I get the same error running locally unless I drop the -Ddw.... arguments.


Appreciate the help!

Coda Hale

unread,
May 29, 2013, 10:22:40 AM5/29/13
to dropwiz...@googlegroups.com
That won't work with 0.7.0, no. It's not a magic system property, it's the dotted path of the JSON/YAML you're intending to override.



--
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 dropwizard-us...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--
Coda Hale
http://codahale.com

James Wyatt

unread,
May 29, 2013, 12:08:42 PM5/29/13
to dropwiz...@googlegroups.com
Thank you! I'm trying to parse the configuration file, but the ConfigurationFactory doesn't seem to list lists. Can anyone help me out with dotted notation for:

server:
  applicationConnectors:
    - type: http
      port: 8080
    - type: https
      port: 8443

I have tried -Ddw.server.applicationConnectors.0.port=8888 using the index for the list, but no luck. Any suggestions?

Coda Hale

unread,
May 29, 2013, 12:40:58 PM5/29/13
to dropwiz...@googlegroups.com
Use the "simple" server factory for 0.7.0. It puts everything on a single port, which you can then override at runtime with "dw.server.port".

This'll all make a lot more sense once I've updated the docs.

James Wyatt

unread,
May 29, 2013, 8:39:18 PM5/29/13
to dropwiz...@googlegroups.com
Thanks, that worked. For reference, this was what worked for me in the Procfile for Heroku:

     web    java $JAVA_OPTS -Ddw.server.connector.port=$PORT -jar dropwizard-example/target/dropwizard-example-0.7.0-SNAPSHOT.jar server dropwizard-example/heroku.yml

Coda Hale

unread,
May 29, 2013, 9:24:33 PM5/29/13
to dropwiz...@googlegroups.com
Yeah, that's the one. I essentially wrote SimpleServerFactory for Heroku users.

Jeremy McJunkin

unread,
Sep 6, 2013, 4:31:41 PM9/6/13
to dropwiz...@googlegroups.com
This doesn't seem to be working now.  Has this changed?  Are there docs available for 0.7.0 yet?

Jeremy McJunkin

unread,
Sep 6, 2013, 4:39:02 PM9/6/13
to dropwiz...@googlegroups.com
So, I see that you say to use the "simple" server factory.  Can you provide a pointer on how to change the server factory used.

Coda Hale

unread,
Sep 6, 2013, 4:54:44 PM9/6/13
to dropwiz...@googlegroups.com
Use the "type" field of the "server" field:

server:
  type: simple
  # etc.

Jeremy McJunkin

unread,
Sep 6, 2013, 5:10:13 PM9/6/13
to dropwiz...@googlegroups.com
Thanks, got it to start up via port from command line now, however, I get 404's for all of my requests which work fine with the default server type. Is there some other change that I need to make?

Jeremy McJunkin

unread,
Sep 6, 2013, 5:30:05 PM9/6/13
to dropwiz...@googlegroups.com
After digging in the code, I found I had to prefix all of my paths with /application

Could the path's printed in the console be updated to include this?
Reply all
Reply to author
Forward
0 new messages