26 March 2021
Instantiating a Maven archetype is a convenient way to start a Java development project without any headache of the setup. Unfortunately, I haven't found any Maven archetype for Wildfly Bootable JAR projects. Instead of creating an archetype myself, I found another efficient way to get the setup of a Wildfly Bootable JAR project done.
The Microprofile Starter Page lists Wildfly as supported runtime:
After extracting the downloaded project package, you’ll happily notice that a Wildfly Bootable JAR project is setup. The configured Galleon layers are configured according to the selected MP specifications.
The setup project can already be build by mvn package
and the application
executed. Although, you’re ready to add the business logic to your application,
I recommend to upgrade the Wildfly Bootable JAR plugin and the Wildfly
application server, both are not up to date in the MicroProfile Starter setup.
The Maven plugin is defined in the <build>
section of the project’s POM,
apparently. You’ll find the latest plugin on
Maven Central. At the time of writing the latest released version is
4.0.1.Final
.
The version of the Wildfly application server is also defined in the project’s
POM. In this case the <properties>
section contains the configuration:
<properties>
<maven.compiler.target>11</maven.compiler.target>
<version.wildfly>22.0.1.Final</version.wildfly> (1)
<failOnMissingWebXml>false</failOnMissingWebXml>
<maven.compiler.source>11</maven.compiler.source>
<final.name>wildfly-starter</final.name>
</properties>
1 | The version of the Wildfly application server. |
The available versions are listed on the Wildfly Download Page.
The command mvn clean package
builds the application. By submitting the
command java -jar target/wildfly-starter-bootable.jar
the application
can be started from the command line. The application server logs to the
console. In order to test the application, cURL
can be used in another
shell:
$ curl localhost:8080/data/hello -v
* Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to localhost (127.0.0.1) port 8080 (#0)
> GET /data/hello HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.68.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Connection: keep-alive
< Content-Type: application/octet-stream
< Content-Length: 11
< Date: Sun, 21 Mar 2021 15:57:06 GMT
<
* Connection #0 to host localhost left intact
Hello World
That’s it, very easy and straight forward. Happy MicroProfiling with Wildfly Bootable JAR…