Build WARs from your Dropwizard apps
Latest commit 8999b1d Mar 25, 2015 @ChristerF ChristerF Merge pull request #9 from juggernaut/jersey-properties
Add method to set jersey properties

WizToWar - Have your cake and eat it too

WizToWar is a simple library that enables a Dropwizard service to also be deployable in a WAR container such as Tomcat.

By following the steps in the usage section below you will be able to create both a Dropwizard jar and a WAR of the same service.

Caveat emptor:

  • Only tested on Tomcat 7
  • No support for bundles
  • Many features untested
  • Goes against the whole philosophy of Dropwizard...


Include the wiztowar jar as a dependency:


Create a new class for your application like this:

package com.twilio.mixerstate;

import com.twilio.wiztowar.DWAdapter;
import com.yammer.dropwizard.Service;


public class MixerStateDWApplication extends DWAdapter<MixerStateServiceConfiguration> {
    final static MixerStateService service = new MixerStateService();

    * Return the Dropwizard service you want to run.
    public Service getSingletonService(){
         return service;

    * Return the File where the configuration lives.
    public File getConfigurationFile() {

        URL url = Resources.getResource("mixer-state-server.yml");
        try {
            return new File(url.toURI());
        } catch (URISyntaxException e) {
            throw new IllegalStateException(e);

Create a main/webapp/WEB-INF/web.xml file:

<?xml version="1.0" encoding="UTF-8"?>
    <!--- This listener is required to hook in to the lifecycle of the WAR -->

Make sure you also build a WAR artifact

There are two alternatives to building a war:

a. Add instructions to also build a WAR

This goes in <build><plugins> section:


b. Change packaging of your Dropwizard service

If you do not intend to run the Dropwizard service standalone, you can simply change the "packaging" element in pom.xml to be "war" instead of "jar".