Deployments using ShrinkWrap

ShrinkWrap is an open-source project sponsored by Red Hat. It provides an API and SPI for easily creating, importing, exporting and manipulating archives. ShrinkWrap works in-memory, but can also be used to create archives on disk.

ShrinkWrap Basics

The primary entry-point into ShrinkWrap is the ShrinkWrap class and its create(class) method. You can create simple Java or Web archives (.jar and .war, respectively) by passing JavaArchive.class or WebArchive.class to the create(…​) method.

WildFly Swarm additionally makes other types of archives available, depending on which fractions you include in your application. While they all ultimately produce a Java archive, they provide additional logic to make building certain types of archives easier.

The types of archives that WildFly Swarm makes available includes, but is not limited to:

Type Description


An enhanced version of .jar which provides easy methods for adding dependencies.


An enhanced version of a .war which provides easy methods for serving static content or adding dependencies.


Web archive which can automatically create the necessary default Application/@ApplicationPath bindings.


Archive type which injects keycloak.json and sets up security constraints


Archive which can register Ribbon-based services or clients

Using Several Types of Archives

Each ShrinkWrap archive type is effectively a view onto the underlying archive. Using the archive’s own .as(class) method, the view can be changed several times while constructing it.

// First create and use generic JAX-RS archive
JAXRSArchive deployment = ShrinkWrap.create( JAXRSArchive.class );
deployment.addResource( MyResource.class );

// Next, view it as a Secured archive, which activated Keycloak Secured.class )

// Then, view it as a RibbonArchive, and set its service name for discovery RibbonArchive.class ).setApplicationName( "my-service" );