In this post, I’ll show you a precise method to install, upgrade or downgrade WildFly to an arbitrary release version – all without leaving the command line. As an additional tip, we’ll add to our shell environment utility commands to execute the server process as a background job and read the server log file.
Let’s proceed.
Requirements
- JDK 1.8 or newer
- Apache Maven 3.3.4 or newer
- Git 2.19.1 or newer
Get WildFly
The first step, of course, is to clone the project.
$ git clone https://github.com/wildfly/wildfly
If you have already done so, just sync your local repository with the upstream.
$ git pull
Thank you, open source! 🙏🏽
Choosing a WildFly version
Here’s the trick: WildFly developers use Git tags to mark release versions. We can show the available WildFly release versions, from earliest to latest, simply by listing the tags.
$ git tag -l ... 13.0.0.Final 14.0.0.Beta1 14.0.0.Beta2 14.0.0.Final 7.0.0.Alpha1 7.0.0.Alpha1-final ..
Suppose we want to install the version 14.0.0 Final. Firstly, let’s check out a new branch (called ‘v14’) whose HEAD would point to the commit identified by the 14.0.0 Final tag.
$ git checkout -b v14 14.0.0.Final Checking out files: 100% (10132/10132), done. Switched to a new branch 'v14'
Build WildFly
Now that we have restored the 14.0.0 Final release, we can build and install WildFly using Maven. Notice that we pass the options ‘-q’ to suppress warnings and ‘-DskipTests’ to speed up the build process. Errors will still be shown, if any.
$ mvn clean install -DskipTests -q
This is going to take a while, so now would be a good time for a cup of coffee.
Environment configuration
Did the build succeed? Great.
Next we can define a shell utility to start up the server in standalone mode – which is what most people would would want. Additionally, we can define a second utility to read the WildFly log file. To make both commands permanently available, we can put them inside a Bash config file such as ~/.bash_aliases or ~/.bashrc.
#!/bin/bash # First we configure the WILDFLY_HOME environment variable export WILDFLY_HOME=~/.m2/repository/org/wildfly/wildfly-build/14.0.0.Final/wildfly-14.0.0.Final/ # Start up WildFly in standalone mode wildfly() { sh $WILDFLY_HOME/bin/standalone.sh 1>/dev/null & } # Read WildFly server log file wildfly-readlog() { less $WILDFLY_HOME/standalone/log/server.log }
Please adjust the value of the WILDFLY_HOME path variable if your local Maven repository is located somewhere else than in your home directory (or if you’re on Windows).
Now let’s verify that the scripts work. Open a new terminal window and type the command:
$ wildfly
The terminal should return to the command prompt, without any output. Normally the standalone.sh script starts the Java server process which prints a rather verbose list of messages and then “hangs”. However, as we execute the startup script in a subshell – notice the control operator ‘&’ appended at the end of the command – we regain control of the command prompt. Also because we redirected output to /dev/null, we won’t be bothered with WildFly’s verbose startup messages. We can still read them from the server log file, at any time, using the wildfly-readlog utility we’ve just created.
From the same terminal window where we started WildFly, we can also conveniently check the process’ status and terminate it, using `kill` utility:
$ jobs [1]+ Running sh $WILDFLY_HOME/bin/standalone.sh > /dev/null & $ kill %1
Configure a management user
The final tip shows how to quickly add a WildFly management user – a required step before we can access the admin console. To do so, we can call the add-user.sh script in non-interactive mode, passing the desired {username} and {password} values.
sh $WILDFLY_HOME/bin/.add-user.sh {username} {password}
Afterwards we can load the admin console at http://127.0.0.1:9990/
That’s all, folks! Hope y’all have enjoyed these tips.