Home » Java » Enterprise Java » Hollowjars, Deployment scanner and why Wildfly swarm is cool

About Phillip Kruger

Phillip Kruger
Phillip is a software developer and a systems architect who knacks for solving problems. He has a passion for clean code and evolutionary architecture. He blogs about all technical things.

Hollowjars, Deployment scanner and why Wildfly swarm is cool

In a previous post I described how you can use OpenLiberty and maven to start the server, either as a standalone, or as part of the maven build, and how to create a fatjar package.

In this post, I am looking at how to do this with Wildfly swarm. I’m still trying to get MicroProfile running on Wildfly full, so for now, this example works differently than the OpenLiberty example.

I am using the same example project, with more maven profiles to run the different deployment options.

(see https://github.com/phillip-kruger/javaee-servers-parent)

Example project

I wanted to include some of the MicroProfile features, so this is a “Quote of the Day” app, instead of a basic “Hello world”. My app uses a factory to load a quote provider (there is only one for now). The current provider gets a quote from forismatic.com. I use the MicroProfile Configuration API to configure things like the URL and the provider to load. I use the MicroProfile Fault Tolerance API to make sure we survive when the provider source is not available.

You can get the full example project here: https://github.com/phillip-kruger/quote-service

Running as part of the maven build

You can use the wildfly-swarm-plugin to run (mvn wildfly-swarm:run) a wildfly swarm instance as part of the build. This plugin will do “fraction detection”, meaning it will look at what parts of the application server you need and only create a deployment with those fractions included. So you can still include the umbrella API’s in your dependencies and code against those, but at deployment time, you will get the right size distribution. Cool !

        <!-- Java EE -->
        <!-- MicroProfile -->

I always use filtering when including HTML files that reference webjars, but it seems like the plugin uses the original source file before filter applies, so I had to find an alternative.


In this example I am using Semantic UI to build a webpage that displays the quote of the day:

I use the maven properties for the versions of the CSS and JS in the HTML, and need to replace them with the real value when we build:

<link rel="stylesheet" type="text/css" href="webjars/semantic-ui/${semantic-ui.version}/dist/semantic.min.css">
    <script type="text/javascript" src="webjars/jquery/${jquery.version}/dist/jquery.min.js" />
    <script type="text/javascript" src="webjars/semantic-ui/${semantic-ui.version}/dist/semantic.min.js"></script>

As an alternative I use the package goal and then the exec-maven-plugin to run the jar.

This also allows me to pass in a standalone.xml for any extra configuration:



In my case the standalone.xml only contains the logging configuration, but you can now include any other configuration.

<server xmlns="urn:jboss:domain:4.0">
            <subsystem xmlns="urn:jboss:domain:logging:3.0">
                <periodic-rotating-file-handler name="FILE" autoflush="true">
                    <file path="${wildfly-swarm.logfile}"/>
                    <suffix value=".yyyy-MM-dd"/>
                    <append value="true"/>
                    <level name="INFO"/>
                        <handler name="FILE"/>
                <logger category="${log.name}">
                    <level name="${log.level}"/>

So in the qoute-service example you can just do this (same as the OpenLiberty example):

mvn clean install -P wildfly-swarm-fatjar


Wildfly swarm allows you to create a hollowjar. (see this article) That is, a fatjar without your application, just the application server part. You can then provide the application as a command line input:

java -jar myapp-hollow-swarm.jar myapp.war

So if we can get a way to reload the app part, we can have the same development model as with a full application (hot deploy).

Deployment scanner

Wildfly swarm has a fraction called deployment scanner, that you can include in your distribution (fat or hollow).

The fraction detection will not auto detect this (as there is no reference to this in the code). Luckily you can define additional fractions in maven:


For this scanner fraction to work, add this to your standalone.xml

<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">

If you now move an updated version of your app to the defined path you have hot deploy.

In the quote example, this means you can:

  • mvn clean install -P wildfly-swarm-start (to start the server)
  • mvn clean install -P wildfly-swarm-deploy (to hot deploy to the running server)
  • mvn clean install -P wildfly-swarm-stop (to stop the running server)

You can also create a fatjar:

  • mvn clean install -P package

Saving time

To build and start a fatjar takes about 10 seconds. To do a hot deploy takes about 2.7 seconds.
That is a huge time saving, making the turn around time between changes much quicker.

Published on Java Code Geeks with permission by Phillip Krüger, partner at our JCG program. See the original article here: Hollowjars, Deployment scanner and why Wildfly swarm is cool.

Opinions expressed by Java Code Geeks contributors are their own.

(0 rating, 0 votes)
You need to be a registered member to rate this.
Start the discussion Views Tweet it!
Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Inline Feedbacks
View all comments