Skip to content
A sample REST application written in Java (dropwizard, guice, jpa, hibernate, cors and more)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Build Status


This a sample REST application written in Java. It's purpose is to create a generic project that can be used as a starting point for a new project, but also for learning efforts (I am building an open game database at

  • built on Dropwizard version 0.7.0
  • dependency injection with Google Guice (no Spring dependencies!)
  • Hibernate / JPA 2.1 as database access framework
  • HSQLDB as database
  • read database configuration from Dropwizard yaml config file, persistence.xml is not used
  • "Session-per-HTTP-request" with Guice PersistentFilter
  • suport for cross-origin resource sharing
  • JPA entities with UUIDs as primary keys
  • Auditing/Version control of entities with hibernate envers
  • authentication with JSON Web Token via dropwizard-auth-jwt
  • Integration tests with rest-assured
  • a pattern for accessing and manipulation entities with HTTP REST calls (Resource => Service => DAO => entity)
  • a pattern for ServiceResult objects which contain ServiceErrorMessages (which can later be bound to web form fields in the client)

Feel free to suggest corrections, optimizations or extensions via pull requests!

A corresponding JavaScript client application (AngularJS) is available at

system architecture

road map / things to do

  • more complex entities
  • hypermedia / HATEOAS


  • Start the application with the class "ToDoApplication" with the parameters "server todo.yml".

  • List all tasks with:

      GET => http://localhost:8080/task
  • Add a new task with:

      POST => http://localhost:8080/task



    JSON-Body e.g. :

      {"name" : "task 1", "description" : "This is a description"}
  • Modify a task:

      PUT => http://localhost:8080/task/[id]



    JSON-Body e.g.:

      "id": "402880944687600101468760d9ea0000",
      "version": "0",
      "name": "task 1 with new name",
      "description": "This is an updated description",
      "finished": "false"
  • Remove a task:

      DELETE => http://localhost:8080/task/[id]
  • List all revision numbers of a task with:

      GET => http://localhost:8080/task/[id]/revisions
  • Show a single task with:

      GET => http://localhost:8080/task/[id]      
  • Show a special revision of a single task with:

      GET => http://localhost:8080/task/[id]/revisions/[revisionNumber]
  • Create JSON Web Token for authentication:

      POST => http://localhost:8080/jwt/login?username=[username]&password=[password]
      e.g. with user1/password1 or user2/password2
  • Check if your JSON Web Token is valid for authentication:

      GET => http://localhost:8080/jwt/test
      Authentication-Header: "Bearer [token]"

I recommend you use the great chrome extension Postman to make such HTTP calls!

Data model


You can’t perform that action at this time.