WildFly Swarm Logo

Do you like JavaEE apps, but wonder how to fit them into a microservices-centric workflow? WildFly Swarm is the answer.

I know—“Java” and “microservices” are not words that seem to go together. Java is an old, relatively unsexy programming language. It’s a pretty useful one, but it was created long before the era of Continuous Delivery, containers and microservices.

But that doesn’t mean you have to give up on Java if you want to take advantage of microservices. WildFly Swarm makes it easy to split the difference between Java development and microservices deployment by sizing down your JavaEE apps.

Keep reading for an overview of how WildFly Swarm optimizes JavaEE deployment, and a quick guide to getting started with WildFly Swarm.

How WildFly Swarm Works

In September 2016, the most recent version of WildFly Swarm (2016.9), was released. WildFly Swarm builds on the foundation of WildFly, the JavaEE application server formerly known as JBoss, to better facilitate Java EE microservice development.

Simply put, WildFly Swarm lets you take a JavaEE app and boil it down to only the essential parts necessary to run it as an uber-JAR file. The result is a leaner, meaner way to deploy Java apps.

If this sounds a bit like unikernels, that’s because it is. But while unikernels in general are a cool idea that has yet to be widely implemented in practice, WildFly Swarm is here and ready for production now.

Why WildFly Swarm?

At this point, you may be wondering why you’d want to include a customized application service inside an uber-JAR with your application. After all, it’s not as if traditional Java application servers are the biggest thing taking up space on your infrastructure. And Java deployments via WildFly are already pretty fast.

That said, why run your Java apps in an application server that has many pieces that aren't used? By cutting out the fat via WildFly Swarm, you get an app and application server combined uber-JAR that sucks up less memory, and is more responsive. Plus, by eliminating unnecessary overhead, they improve security because they reduce your apps’ exposure.

Packaging as an uber-JAR is a perfect fit for providing a single artifact to be passed through the entire CI/CD pipeline. While also ensuring that what was tested is exactly what's in production, as there are no longer any concerns with differing application server configurations between environments.

In short, WildFly Swarm lets you fully embrace all the benefits of a microservices-oriented development and deployment workflow. You no longer have to take a monolithic approach to building and running JavaEE apps. Instead, you can compile and deploy just the parts you need, and leave out everything you don’t.

Setting Up WildFly Swarm

Excited yet? If not, consider also that deploying WildFly Swarm is pretty trivial if you already have a Java EE project. You just add the wildfly-swarm-plugin to your pom.xml file between plugin tags, like so:

<plugin>
  <groupId>org.wildfly.swarm</groupId>
  <artifactId>wildfly-swarm-plugin</artifactId>
  <version>${version.wildfly-swarm}</version>
  <executions>
    <execution>
      <phase>package</phase>
      <goals>
        <goal>package</goal>
      </goals>
    </execution>
  </executions>
</plugin>

You also need a dependency block like:

<dependency>
    <groupId>org.wildfly.swarm</groupId>
    <artifactId>jaxrs</artifactId>
    <version>${version.wildfly-swarm}</version>
    <scope>provided</scope>
</dependency>

From there, you just build your project. You’ll get a WildFly Swarm-enabled JAR, which will put a traditional application server to shame in terms of leanness and resource optimization.

For a deeper dive into what WildFly Swarm can do, you can check out examples on GitHub. And complete documentation is available from the WildFly Swarm website.

 

About Chris

Screen Shot 2016-08-16 at 1.29.59 PMChris Tozzi has worked as a journalist and Linux systems administrator. He has particular interests in open source, Agile infrastructure and networking. He is Senior Editor of content, and a DevOps Analyst at Fixate IO.

Last updated: October 17, 2018