https://github.com/twilio/wiztowar
Build WARs from your Dropwizard apps
https://github.com/twilio/wiztowar
Last synced: 10 months ago
JSON representation
Build WARs from your Dropwizard apps
- Host: GitHub
- URL: https://github.com/twilio/wiztowar
- Owner: twilio
- License: mit
- Created: 2013-11-04T06:44:11.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2023-04-10T02:17:25.000Z (about 3 years ago)
- Last Synced: 2024-04-10T09:49:47.651Z (about 2 years ago)
- Language: Java
- Homepage:
- Size: 303 KB
- Stars: 40
- Watchers: 22
- Forks: 18
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-dropwizard - WizToWar - Build WARs from your Dropwizard apps (Open Source / Deployment)
README
WizToWar - Have your cake and eat it too
========================================
WizToWar is a simple library that enables a [Dropwizard](http://dropwizard.io) 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...
Usage
------
Include the wiztowar jar as a dependency:
```xml
com.twilio
wiztowar
1.3
```
Create a new class for your application like this:
```java
package com.twilio.mixerstate;
import com.google.common.io.Resources;
import com.twilio.wiztowar.DWAdapter;
import com.yammer.dropwizard.Service;
import java.io.File;
import java.net.URISyntaxException;
import java.net.URL;
public class MixerStateDWApplication extends DWAdapter {
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.
*/
@Override
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
com.twilio.mixerstate.MixerStateDWApplication
```
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 `` section:
```xml
org.apache.maven.plugins
maven-war-plugin
2.4
default-war
package
war
target/webapp
```
### 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".