Many agree that Dropwizard
is one of the best new service frameworks for Java services out
there - and Twilio engineering certainly agrees with that. Most of
the Java world has moved on from Java Enterprise Edition
(JEE), but what if you have to deploy your application in a JEE server? Will you still be stuck with old-school JEE?
It would make Coda Hale nauseous, but we decided we can have our cake and eat it too. We created WizToWar, a simple utility library that lets you have all the goodness of Dropwizard, while still creating deployable WARs for a JEE server.
Why JEE in the first place?
But why deploy in a JEE server in the first place? After having gotten used to the simplicity and manageability of Dropwizard services it is easy to pull your hair when you have to go back to a JEE server again. (This is the point where JEE 6/7 advocates will start disagreeing vehemently). Our services also have to support SIP connectivity, and we have concluded that the SIP Servlets API (JSR-289) is the most suitable API for that. If you are allergic to JEE, this is where the rash starts - JSR-289 is only supported in JEE environments, integrated with JEE application servers like Websphere, JBoss, Weblogic and Tomcat. And unfortunately there isn’t yet a SIP Servlet container integrated with Dropwizard.
Our need and love for SIP unfortunately leads us down the JEE rabbit hole. For others it might be corporate policies, legacy environments or simply integration requirements.
Is Dropwizard JEE's 15 year younger, leaner and better looking cousin?
What is Dropwizard anyway? One view of Dropwizard is that it is "JEE, the good parts" as it cleverly reuses open source implementations of key JEE specifications including HTTP Servlets (Jetty), JAX-RS (Jersey) and Java Bean Validation (Hibernate Validator).
What sets Dropwizard apart from JEE though is how it makes a single standalone Java application expose standardized lifecycle management, metrics, monitoring and health checks without going through a separate server. Dropwizard applications hook in to Dropwizard's own APIs for configuration, lifecycle management and monitoring.
So Dropwizard is JEE's 15 year younger, leaner and better looking cousin with an opinionated attitude. If they met on the street, Dropwizard would totally pretend he didn't know JEE.
WizToWar - mixing oil and water
If you would simply change the packaging of your Dropwizard application to "war" and try to deploy the resulting WAR, unfortunately nothing happens.
WizToWar fixes that by acting as the glue that hooks in to the lifecycle of the WAR, initializes and feeds the Dropwizard service its configuration and registers its services (servlets, Jersey resources and Healthchecks) with the surrounding JEE Server.
WizToWar basically emulates what happens when you launch the "server" command for a Dropwizard application and translates that to the JEE server.
Having your cake and eating it too
With WizToWar you can generate a normal Dropwizard service and a WAR from the same source - in the same build.
You just need to add an adapter class, a configuration file (web.xml) and some additional build instructions (to also generate a WAR). You can find detailed instructions on how to get started on GitHub where we are hosting this open source project.
WizToWar enables us to continue to standardize on the Dropwizard programming model even for services that also require SIP connectivity and in the process streamline how we manage, configure and develop both SIP and HTTP-based services.