A sample microprofile application using wildfly bootable jar

In the current post I’m going to show how someone can create a bootable jar ( Fat JAR ) by using Wildfly as the container runtime. Recent versions of Wildfly fully support this new way of packaging applications. A bootable JAR allows you to package both the server and your application deployment inside a single JAR file and execute it with a simple command such as :

java -jar app-bootable.jar

As it happens with similar frameworks like Spring Boot and Quarkus , there is a maven plugin which creates the bootable jar.
The plugin can be found here ( along with examples and details on how to use it )
https://github.com/wildfly-extras/wildfly-jar-maven-plugin/

One key difference with the classical Wildfly usage is that the server works only in standalone mode. But honestly, who needs the domain mode with this approach. A second instance of the application will be another bootable jar and not a second server within a wildfly cluster in a master/slave mode.

Furthermore, the server can’t be started in admin mode. Although, the Wildfly Configuration can be achieved by using the wildfly-jar-maven-plugin. From the plugin configuration element, you need to provide the WildFly Galleon feature-pack and the list of Galleon layers you want to include/exclude.The WildFly Galleon feature-pack is a maven artifact that contains everything needed to dynamically provision a server.

You can find more documentation here
https://www.wildfly.org/news/2021/03/19/bootable-jar-4.0.Final-Released/

The official wildfly bootable jar documentation can be found here
https://docs.wildfly.org/bootablejar/#wildfly_jar_advanced_upgrade

I have created a sample application which involves jaxrs/cdi/jpa with postgres.
The application also has microprofile capabilities like healthiness/liveness and openapi.
The application can be used as a template and someone can see how the plugin can be configured in order to achieve a specific wildfly setup ( cli scripts, jdbc datasources, logging etc).

You can find the source code here

https://github.com/sergouniotis/inventory-service

There is also a docker-compose file for the dockerized version of the wildfly bootable jar along with a postgres container which is used by the persistent layer. The docker-compose file can be found here
https://github.com/sergouniotis/inventory-docker-compose

Leave a Reply

Your email address will not be published. Required fields are marked *