Introduction
Dropwizard is a Java framework for developing ops-friendly, high-performance RESTful web services. Instead of assembling components yourself, Dropwizard packages battle-tested libraries — Jetty for HTTP, Jersey for REST, Jackson for JSON, and Metrics for monitoring — into a cohesive stack with sensible defaults.
What Dropwizard Does
- Runs as a self-contained fat JAR with an embedded Jetty server
- Exposes RESTful endpoints using JAX-RS (Jersey) annotations
- Serializes and deserializes JSON with Jackson, including validation via Hibernate Validator
- Collects operational metrics (timers, counters, health checks) out of the box
- Manages database connections through JDBI or Hibernate bundles
Architecture Overview
A Dropwizard application is a standard Java main() method that initializes the framework, reads a YAML configuration file, and starts an embedded Jetty server. The application registers resource classes (JAX-RS endpoints), health checks, and managed lifecycle objects. Two separate Jetty connectors serve application traffic and an admin interface (metrics, health checks, thread dumps) on different ports. Configuration is type-safe: YAML keys map to Java objects validated at startup.
Self-Hosting & Configuration
- Requires JDK 11+ and Maven or Gradle for building
- Application settings are defined in a YAML file passed as a command-line argument
- Environment variables can override YAML values using the
SubstitutingSourceProvider - Build a fat JAR with
mvn packageand run directly withjava -jar - Deploy as a systemd service, Docker container, or on any JVM-hosting platform
Key Features
- Admin port exposes health checks, thread dumps, and Prometheus-compatible metrics
- Configuration validation catches misconfigurations at startup, not at runtime
- Views bundle supports server-rendered HTML with Mustache or Freemarker templates
- Authentication filters for Basic, OAuth2, and custom auth schemes
- Lifecycle management for background tasks, scheduled jobs, and graceful shutdown
Comparison with Similar Tools
- Spring Boot — Larger ecosystem with auto-configuration; Dropwizard is more explicit and produces smaller binaries
- Quarkus — GraalVM native compilation for fast startup; Dropwizard uses traditional JVM with proven library choices
- Micronaut — Compile-time DI and low memory; Dropwizard relies on runtime reflection but has a simpler mental model
- Vert.x — Reactive and polyglot; Dropwizard is blocking by design with thread-per-request simplicity
FAQ
Q: Is Dropwizard still actively maintained? A: Yes. Dropwizard 4.x is the current major version with ongoing development and releases.
Q: How does Dropwizard handle dependency injection? A: Dropwizard uses HK2 (bundled with Jersey) for DI. Community bundles add Guice or Dagger support.
Q: Can Dropwizard serve a single-page application?
A: Yes. The assets bundle serves static files from the classpath, and you can configure a fallback to index.html for client-side routing.
Q: What is the admin port used for? A: The admin connector (default port 8081) serves operational endpoints: health checks, metrics, CPU profiles, and log-level management — separate from application traffic.