Introduction to Dropwizard


Simon Skoczylas Senior Software Developer
Materna GmbH

Java, JavaScript
Web, Frontend

What’s a Dropwizard?

A character in a K.C. Green web comic.

Dropwizard is a Java framework for developing ops-friendly, high-performance, RESTful web services.

Dropwizard pulls together stable, mature libraries from the Java ecosystem into a simple, light-weight package that lets you focus on getting things done.
Dropwizard has out-of-the-box support for sophisticated configuration, application metrics, logging, operational tools, and much more, allowing you and your team to ship a production-quality web service in the shortest time possible.

Best-of-breed Java libraries

Best-of-breed Java libraries

More modules


  • First release v0.1.0 in 2011 by Coda Hale at Yammer
  • v0.7.0 dropped Scala support (04.04.2014)
  • Release v1.0.0 (26.07.2016)
    • Using Java 8 as baseline
  • Current release v1.0.2 (23.09.2016)

Main components

  • Configuration
  • Application
  • Representation
  • Resource
  • Health check


Configuration file


#server configuration
- type: http
port: 8080

- type: https
port: 8443
keyStorePath: example.keystore
keyStorePassword: example
validateCerts: false
validatePeers: false

fancyCoolProperty: Look at me I am cool and fancy

# Database settings.
# the name of your JDBC driver
driverClass: org.h2.Driver

# the username
user: sa

# the password
password: sa

# the JDBC URL
url: jdbc:h2:./target/example

Configuration class


public class ApplicationConfiguration extends Configuration {

private String fancyCoolProperty;

public String getFancyCoolProperty() {
return fancyCoolProperty;

public void setFancyCoolProperty(String fancyCoolProperty) {
this.fancyCoolProperty = fancyCoolProperty;


Application class

public class HelloWorldApplication extends Application<ApplicationConfiguration> {

public String getName() {
return "hello-world";

public void initialize(Bootstrap<ApplicationConfiguration> bootstrap) {
// nothing to do yet

public void run(ApplicationConfiguration configuration, Environment environment) {
// nothing to do yet




public class Saying {

private String content;

public Saying() {
// Jackson deserialization

public Saying(String content) {
this.content = content;

public String getContent() {
return content;



  • The meat-and-potatoes of Dropwizard
  • JAX-RS API (Jersey)


public class HelloWorldResource {

public Saying sayHello(@QueryParam("name") Optional<String> name) {
final String value = name.orElse("unkown");
return new Saying(value);


Registering a resource

public void run(ApplicationConfiguration configuration, Environment environment) {

final HelloWorldResource resource = new HelloWorldResource();


Health check

Provided by Dropwizard Metrics
A health check is basically a small self-test which your application performs to verify that a specific component or responsibility is performing correctly.

Health check

public class SimpleHealthCheck extends HealthCheck {

protected Result check() throws Exception {
//check some stuff here!

return Result.healthy("Everything is fine");


Registering a health check

public void run(ApplicationConfiguration configuration, Environment environment) {

final SimpleHealthCheck healthCheck = new SimpleHealthCheck();
environment.healthChecks().register("simpleCheck", healthCheck);


Running your application

Do you remember the Java main() method?

public static void main(final String[] args) throws Exception {

final HelloWorldApplication application = new HelloWorldApplication();;


Running your application

  • Within the IDE
  • As Maven or Gradle task
  • As self contained jar
    • Make features not war (JAR not WAR)
    • java -jar application.jar server application.yml

Dropwizard is used by

Some Competitors

Ratpack, Ninja framework, ...


// // Verwendbar über Featuredetection und Polyfills