Wildfly-Proposals - Bootable-Jar - WFLY-13305 - Bootable - Jar - Adoc at Main Wildfly - Wildfly-Proposals
Wildfly-Proposals - Bootable-Jar - WFLY-13305 - Bootable - Jar - Adoc at Main Wildfly - Wildfly-Proposals
wildfly /
wildfly-proposals
categories
bootable-jar
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 1/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
Overview
We are proposing a way to package server and application inside a bootable JAR. The
JAR contains everything needed to run the server. The packaged server can benefit from
Galleon tooling and be trimmed down to user needs (thanks to Galleon layers). Such
executable JAR can then be run on bare metal and in cloud execution contexts.
Issue Metadata
Issue
WFLY-13305
Related Issues
EAP7-1385
EAP7-1538
WFCORE-4895
WFGP-169
EAP7-1444
JKube 283
Dev Contacts
Jean-Francois Denise
QE Contacts
Fabio Burzigotti
Testing By
[ ] Engineering
[X] QE
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 2/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
WildFly Quickstarts
Microprofile starter
Thorntail
Requirements
CLI management operations that would imply a server restart are not supported.
Changes done to the management model (e.g.: using CLI or Web console) at
runtime are not persisted between bootable JAR executions. NB: In order to make
persistent changes to the management model, one can use the WildFly CLI scripts
execution feature that the Maven plugin offers.
org.jboss.galleon:galleon-maven-plugin
org.wildfly.galleon-plugins:wildfly-galleon-maven-plugin
Maven plugin goals to build galleon feature-packs for WildFly are defined in
wildfly/galleon-plugins project
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 3/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
org.wildfly.plugins:wildfly-maven-plugin
Maven plugin goals to manage a WildFly server and its deployments are
defined in wildfly/wildfly-maven-plugin project
It makes sense to define a new Maven artifact for the plugin and not extend an existing
plugin:
The new plugin depends on galleon-maven-plugin for the provisioning aspects but
is WildFly specific. Galleon is only one aspect of it.
Hard Requirements
For a complete list of plugin options, check the plugin community documentation.
User application (WAR, JAR, EAR) unless a hollow bootable JAR is created.
The set of classes that implement the boot logic are retrieved at packaging time. The
new “org.wildfly.core:wildfly-jar-boot” JAR artifact (implementation located in wildfly-
core repository) is resolved thanks to the wildfly-core version of the provisioned server
and shaded into the bootable JAR. If the artifact doesn’t exist, the packaging will abort,
the server being packaged not supporting bootable JAR packaging. (e.g.: old release
not containing new artifacts).
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 4/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
This artifact is in charge to unzip the server and setup a JBOSS_HOME. Once this is
done, it setups JBoss module classloader and call into a new JBoss module
“org.wildfly.bootable-jar” that is in charge of the actual server run. This new JBoss
module implementation located in wildfly-core, (“org.wildfly.core:wildfly-jar-runtime”
artifact), is expected to be automatically provisioned by Galleon in all cases. If the
module is not part of the provisioned server (for some un-expected reasons), the server
execution aborts.
Galleon provisioning
A Galleon feature-pack location that identifies the server and version. This is
required if no provisioning.xml file is provided nor feature-packs list.
Galleon provisioning.xml file path. By default the plugin checks for the presence of
the file <app src>/galleon/provisioning.xml. NB: Maven plugin configuration items
(if set) override provisioning.xml file. Using the provisioning.xml file, third-parties
feature-packs can be combined during the provisioning phase to provision
modules, features, content (e.g.: DB drivers).
The following invalid configurations are detected during Maven plugin execution:
Including a swapping layer along with its base layer without excluding the
swapping counter-part (eg: jaxrs + jpa-distributed without excluding jpa) breaks
execution of the plugin. The plugin attempts to generate the server configuration
but fails due to conflicting layers provisioned content.
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 5/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
Excluding a non optional layer (non optional layers are required layers) breaks
execution of the plugin.
Including and excluding the same layer breaks execution of the plugin.
NB: Including or excluding multiple time the same existing layer is not considered an
error. Galleon manages to deal with duplicates.
In order to have management model changes persisted in the server configuration, the
Maven plugin offers a support for CLI script(s) execution. The changes made to the
management model during build are persisted in the bootable JAR (as opposed to
changes done to the management model at runtime that are lost after a process
restart).
When building the bootable JAR, a path to a set of CLI scripts can be provided to
update the server configuration packaged in the bootable JAR. The CLI scripts are
concatenated and executed once the server is provisioned and deployment copied into
it (if any). Having multiple CLI scripts provides enough flexibility to reuse scripts in
different contexts. The plugin can be configured with a CLI properties file to resolve
properties present in CLI scripts. This is similar to the --properties=<properties file>
option that you can provide to JBoss CLI command line. This article covers the feature.
CLI script files are text files that contain a sequence of WildFly CLI commands.
Commands can be CLI defined commands (some builtin commands allowing to achieve
complex sequence of server operations) and generic management operations to be
sent to the server. Some examples can be found in WildFly administration guide CLI
recipes chapter.
In the context of Bootable JAR, the script does not need to contain commands to
connect to the server or start an embedded server. The Maven plugin handles that for
you by starting an embedded server for each group of scripts.
The plugin allows you to execute multiple groups of scripts with different CLI contexts.
A group of scripts and its configuration are defined in a cli-session composed of:
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 6/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
expressions are resolved before sending the operation requests to the server. Value
is true by default.
All scripts present in a cli-session are executed within a single CLI execution. An
embedded server is started for each defined cli-session .
NB: The scripts are executed in the order they are defined in the plugin configuration.
<cli-sessions>
<cli-session>
<script-files>
<script>../scripts/script1.cli</script>
</script-files>
<!-- We want the env variables to be resolved during server
execution -->
<resolve-expressions>false</resolve-expressions>
</cli-session>
<cli-session>
<script-files>
<script>../scripts/script2.cli</script>
</script-files>
<properties-file>../scripts/cli.properties</properties-file>
<!-- We want the properties to be resolved during CLI execution (not
actually needed, this is the default behavior) -->
<resolve-expressions>true</resolve-expressions>
</cli-session>
</cli-sessions>
User application
The WAR or JAR main artifact the Maven project is building is deployed and zipped
along with the server. The plugin option context-root=true|false (true by default) allows
to rename the war file to ROOT.war (doesn’t apply to other packaging types).
NB: Application deployment doesn’t rely on the deployment scanner. The scanner is not
required, it is even suggested to exclude it, useless in a bootable JAR context. For an
example of how to exclude the deployment-scanner Galleon layer, you can check this
example
Hollow JAR
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 7/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
Logging
Log manager
The bootable JAR depends on JBoss log manager. Logging is configured thanks to the
logging subsystem.
During packaging the maven plugin generates a logging.properties file that reflects the
server logging configuration.
When WildFly server starts, in order to have JBoss logging enabled and configured
before the logging subsystem is initialized, WildFly relies on a logging.properties file
that configures JBoss logging. WildFly distribution contains a default logging.properties.
In a bootable JAR context, we could have CLI scripts that tune the logging subsystem.
So at boot, if the logging.properties file was the WildFly distribution default one, the
logging subsystem changes done by CLI scripts would be not taken into account before
the logging subsystem is initialized. By generating a logging.properties from the
logging subsystem, we capture the logging subsystem configuration. At boot, JBoss
logging uses this file so it is configured in an identical way as the logging subsystem.
NB: The logging subsystem defaults come from the "logging" Galleon layer (that
contains a configuration identical to WildFly default xml configurations). If no logging
subsystem is present in the server configuration (so no Galleon logging layer
provisioned), we rely on the default loging.properties file.
You can workaround this by supplying your own logging.properties and defining the
path in the boot-logging-config maven plugin’s configuration property. The wildfly-
jar-maven plugin log4j example contains such a workaround.
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 8/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
Handle arguments
Alternatively the Maven plugin can be used to run/shutdown the server from Maven
wildfly-jar:run|start|shutdown.
The bootable JAR fully relies on the server configuration capabilities. It is not expected
to define a new way to configure the server. The arguments passed to the bootable JAR
are composed of bootable specific arguments and server arguments.
Calling java <JVM and system properties> -jar <bootable JAR name>.jar --help dumps
the available arguments.
SecurityManager
The bootable JAR can activate the WildFlySecurityManager for the running application
server if the -secmgr command line argument is added when starting the server.
Security
Examples and documentation should be using Elytron security where required and not
the legacy security subsystem or legacy security realms as both of these are deprecated
for removal in a future release.
Signal handling
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 9/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
The restart option is not supported and would be ignored by the server. The
process will exit in all cases.
The changes made to the management model are not reflected in the standalone.xml
file. Having the configuration file to reflect runtime changes is not needed, as already
described, changes done to the management model are lost after a restart. To make the
configuration file read-only, the server is internally started with --read-only-server-
config=standalone.xml.
Arguments handling
Option Description
--deployment=<path to
Application to install in the hollow JAR. Adding a
WAR/JAR/EAR file or
deployment to an bootable JAR already containing
exploded deployment
a deployment is invalid.
directory>
Server arguments:
Option Description
-D<name>[= Set a system property. The system properties are set by the
<value>] server. They are not set by the bootable JAR JVM.
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 10/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
-S<name>
Set a security property
[=value]
--properties=
Load system properties for the given url
<url>
Developer experience
Having to rebuild a server and package a bootable JAR for each code change is not a
valid approach. The plugin should offer a development mode allowing to make
development using bootable JAR an efficient task. We are defining here a workflow that
leverages the hollow JAR packaging and server deployment scanner capabilities.
Dev mode
The plugin attempts to force the provisioning of the deployment scanner in dev mode:
If the deployment-scanner is not in the config, the CLI operation will abort the
plugin execution and log an error message.
Workflow examples
Description of the 2 workflows (with and without dev mode). These examples could be
designed differently according to the content of the pom file.
Nominal mode, full repackaging of the server done for each rebuild, server restarted
after each rebuild (not viable):
⇒
mvn package -Ddev Fast, no packaging, app copied to deployments dir.
Application automatically re-deployed.
…
mvn wildfly-jar:shutdown
User is fine with his changes, he can do the server+app packaging: mvn package
NB: This workflow doesn’t require support in IDE, it is 100% Maven. It could be
optimized with IDE plugin (e.g.: netbeans plugin to track static files and avoid to re-
package in this case).
Cloud context
The plugin allows to generate a bootable JAR usable in various Cloud execution
contexts: custom container, Google JIB, JKube, Java s2i build.
The Maven plugin configuration item <cloud></cloud> allows to build a bootable JAR
for cloud environment. By default the server is configured to run inside an OpenShift
context. Set the cloud child element <type>openshift|kubernetes</type> to select the
targeted cloud platform.
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 12/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
The microprofile-health and core-tools (that contains WildFly CLI) galleon layers
are provisioned. They are required for the OpenShift probes and WildFly OpenShift
operator to properly operate.
The public and private inet addresses are bound to the value of the HOSTNAME
The management inet address is bound to the 0.0.0.0 inet address allowing for
local (required by WildFly CLI) and remote access (required by OpenShift readiness
and liveness probes).
The jboss.node.name system propery, if not set, is set to the value of HOSTNAME
environment variable if defined (defined in OpenShift PODS). If HOSTNAME is not
set and jboss.node.name is not set, jboss.node.name is not set. The node name
value is truncated to a max of 23 characters in order for the transaction subsystem
to properly operate. The last 23 characters are kept in order to avoid conflicts.
<cloud/>
<cloud>
<enable-jgroups-password>true</enable-jgroups-password>
</cloud>
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 13/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
<cloud>
<type>kubernetes</type>
</cloud>
The WildFly OpenShift operator can be used to manage deployments based on image
containing a WildFly bootable JAR. At boot time, the WildFly bootable JAR dumps in the
file /opt/jboss/container/wildfly-bootable-jar/install-dir its installation path. This
information is required by the WildFly OpenShift operator to retrieve transaction logs
and call into WildFly CLI.
The JKube Maven Plugin (version 1.0.0-rc-1 for now) has been evolved with a generator
that recognizes the bootable JAR maven plugin. An example of Bootable JAR Maven
plugin and JKube Maven Plugin to deploy application on OpenShift and Kubernetes.
More information on the JKube Maven plugins can be found in JKube documentation
Nice-to-Have Requirements
Add the ability to copy content in the server during build. That is a common
requirement (e.g.: auth properties files).
Non-Requirements
Offer a new way to configure the server (e.g.: Thorntail yaml file).
Package a custom standalone XML file. Standalone XML file is generated during
build by the Maven plugin and can’t be replaced.
Usage of a different log manager than JBoss log manager is out of scope.
No domain support.
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 14/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
Implementation Plan
Evolve wildfly-core with a runtime to boot the bootable JAR.
Test Plan
Maven plugin tests (in plugin repo)
Wildfly-core tests (in wildfly-core repo). Run existing tests (when applicable) against
bootable JAR using the -Dts.bootable maven profile: cd <wildfly repo>/testsuite; mvn
clean install -Dts.bootable
Community Documentation
Maven plugin documentation
cd docs
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 15/16
2024. 03. 10. 16:50 wildfly-proposals/bootable-jar/WFLY-13305_Bootable_Jar.adoc at main · wildfly/wildfly-proposals
https://github.com/wildfly/wildfly-proposals/blob/main/bootable-jar/WFLY-13305_Bootable_Jar.adoc 16/16