Upgrade Notes for Dropwizard 0.8.x


Check out Migration discussion 0.7.1 to 0.8.0 at the dropwizard-dev mailing list.

Migration of Apache Commons Lang

The classes were moved to a new package. You have to update the corresponding imports:

search for: org.apache.commons.lang.
replace with: org.apache.commons.lang3.

Use assertions from AssertJ

Instead of the FEST assertions you should use the AssertJ assertions:

search for: org.fest.assertions.api.Assertions.
replace with: org.assertj.core.api.Assertions.

Migration of custom URL pattern

If you set a custom URL pattern in your application run method you should move the definition to your configuration file:

Remove from Java code (example):


Add to configuration file (example):

  rootPath: '/api/*'

Migration of Jersey

This is not a simple search and replace migration, so I show you a few examples of often used code snippets for integration testing:

Dropwizard Class Rule

The class rule was not modified. It is shown here because it is used in the examples below.

public static final DropwizardAppRule<SportChefConfiguration> RULE =
                    new DropwizardAppRule<>(App.class, "config.yaml");

Executing a GET request

final WebTarget target = ClientBuilder.newClient().target(
        String.format("http://localhost:%d/api/user/1", RULE.getLocalPort()));

final Response response = target


final User user = response.readEntity(User.class);

Executing a POST request

final WebTarget target = ClientBuilder.newClient().target(
        String.format("http://localhost:%d/api/user", RULE.getLocalPort()));

final User user = new User(0L, "John", "Doe");

final Response response = target


final URI location = response.getLocation();

final String path = location.getPath();
final long newId = Long.parseLong(path.substring(path.lastIndexOf("/") + 1));

Executing a empty PUT request

Jersey 2 does not by default allow empty PUT or DELETE requests. If you want to enable this, you have to add a configuration parameter

Client client = ClientBuilder.newClient();
client.property(ClientProperties.SUPPRESS_HTTP_COMPLIANCE_VALIDATION, true);
WebTarget target = client.target(
        String.format("http://localhost:%d/api/user", RULE.getLocalPort()));

Response response = target


Request/response filters

If you previously used jersey container filters in your Dropwizard app, getContainerRequestFilters() will now fail to resolve:

.add(new AuthorizedFilter());

You might need to rewrite the filter to JAX-RS 2.0 and then you may use the one and only .register() instead.

My filters used imports from jersey.spi.container and needed to be rewritten for Jersey 2.x. See also: Jersey 1.x to 2.x migration guide.

env.jersey().register(new AuthorizationFilter());