Piranha - a cloud container, an exciting, new and in progress project

This project is maintained by piranhacloud

Piranha Embedded

This distribution of Piranha delivers you with an embeddable implementation of a Servlet container. It is used extensively within the Piranha project itself to test all the Servlet functionality.

Example usage

EmbeddedPiranha piranha = new EmbeddedPiranhaBuilder()
    .servlet("SnoopServlet", SnoopServlet.class.getName())
    .servletMapping("SnoopServlet", "/SnoopServlet")

EmbeddedRequest request = new EmbeddedRequestBuilder()

EmbeddedResponse response = new EmbeddedResponseBuilder()

piranha.service(request, response);



The example above adds the SnoopServlet to Piranha Embedded. It creates a GET request at path /SnoopServlet and it create the response. And it then asks Piranha Embedded to process it. And then it asserts the response contains SUCCESS.


We recommend using the EmbeddedPiranhaBuilder to create your instances of EmbeddedPiranha.

Expectations and assumptions

  1. You take care of class loading (if more isolation is needed).
  2. You setup the request object.
  3. You setup the response object.


  1. Only supports one web application per Piranha Embedded instance.

Maven coordinates

Please use the following dependency.


where y is the year, m is the month and p is the patch version of the release you want to use.

Where are the sources?

See GitHub at https://github.com/piranhacloud/piranha/tree/master/embedded