The productivity of your developers is crucial for the success of your project. Without fast deployments and short feedback-cycles about a new feature, you lose a lot of time just “idling”. As a Java/Jakarta EE developer, you will most likely have a local installation for the target application server and deploy the application several times a day during development. In the past, I’ve used Eclipse/IntelliJ/Netbeans with various vendor plugins to start the application server and deploy on every new code change. This was always quite a fiddling task, as I sometimes got issues with the plugins, had to wait for a new release or it wasn’t as fast as I expected until I could see my changes. Luckily Adam Bien (@AdamBien) solved this with a small Java project called WAD (Watch and Deploy) which deploys thin
.war ‘s on every change to any server and improves your productivity.
In this blog post, I’ll review the project and show you my personal setup.
First, make sure you have Maven installed on your machine and that the
bin folder of Maven is on your
PATH. In addition, you have to set the
MAVEN_HOME environment variable for Linux/Mac and
M2_HOME for Windows to the path of the Maven root folder e.g.
To start with WAD you first have to download the
.jar file from GitHub and place it into your Java/Jakarta EE project folder next to your
pom.xml (for quick Java EE 8 application bootstrapping, have a look at my or Adam’s Maven archetype). With the
.jar file in place, you can now start it with:
java -jar wad.jar [DEPLOYMENT_DIR_OF_APP_SERVER] [DEPLOYMENT_DIR_OF_APP_SERVER] [DEPLOYMENT_DIR_OF_APP_SERVER]
WAD will now watch for changes within
src/main . On every change, the project is built and deployed to the folder you specified during the launch of WAD. You can manually specify application server auto-deployment folders (e.g. for Payara:
.../Payara/glassfish/domains/domain1/autodeploy) separated by spaces or use a global configuration as described in the following section.
With the latest release of WAD, you can even configure the deployment folders in one place with a
.wadrc located in your home/user directory. This file specifies all deployment folders separated by a new line like:
C:\Development\Server\Payara\payara-5.183\glassfish\domains\domain1\autodeploy C:\Development\Server\OpenLiberty\openliberty-220.127.116.11\usr\servers\defaultServer\dropins C:\Development\Server\Wildfly\wildfly-16.0.0\standalone\deployments C:\Development\Server\TomEE\apache-tomee-plume-8.0.0-M2\webapps
With this setup, you can now launch WAD without an additional parameter like:
java -jar wad.jar
and it will detect all deployment folders automatically:
$ java -jar wad.jar wad 0.1.1-SNAPSHOT 'C:\Development\Server\TomEE\apache-tomee-plume-8.0.0-M2\webapps' from ~/.wadrc 'C:\Development\Server\Wildfly\wildfly-16.0.0\standalone\deployments' from ~/.wadrc 'C:\Development\Server\OpenLiberty\openliberty-18.104.22.168\usr\servers\defaultServer\dropins' from ~/.wadrc 'C:\Development\Server\Payara\payara-5.183\glassfish\domains\domain1\autodeploy' from ~/.wadrc resulting deployment folders are: 'C:\Development\Server\TomEE\apache-tomee-plume-8.0.0-M2\webapps' 'C:\Development\Server\Wildfly\wildfly-16.0.0\standalone\deployments' 'C:\Development\Server\OpenLiberty\openliberty-22.214.171.124\usr\servers\defaultServer\dropins' 'C:\Development\Server\Payara\payara-5.183\glassfish\domains\domain1\autodeploy' WAD is watching .\src\main, deploying target\improved-java-ee-productivity-with-wad.war to [C:\Development\Server\TomEE\apache-tomee-plume-8.0.0-M2\webapps\myapp.war, C:\Development\Server\Wildfly\wildfly-16.0.0\standalone\deployments\myapp.war, C:\Development\Server\OpenLiberty\openliberty-126.96.36.199\usr\servers\defaultServer\dropins\myapp.war, C:\Development\Server\Payara\payara-5.183\glassfish\domains\domain1\autodeploy\myapp.war]
During the first launch, your project is initially built and deployed:
[10:51:02] built in 2455 ms Copying 4kB ThinWAR to (...)app.war Copying 4kB ThinWAR to (...)app.war Copying 4kB ThinWAR to (...)app.war Copying 4kB ThinWAR to (...)app.war copied in 6 ms
You can now start the application server of your choice or start all in parallel (when running TomEE/Payara/WildFly in parallel make sure they all start on a different port and not all on 8080) and test your application against every vendor if you want to.
In addition, I personally launch a
tail -f server.log (on Windows I use either Git Bash or MobaXterm for that) for the application server I’m using to see possible errors within the console. Furthermore, I defined aliases to start and run every application server on my machine:
alias startPayara583= C:\Development\Server\Payara\payara-5.183\bin\asadmin.bat start-domain alias stopPayara583= C:\Development\Server\Payara\payara-5.183\bin\asadmin.bat stop-domain alias startOpenLiberty1901= C:\Development\Server\OpenLiberty\openliberty-188.8.131.52\bin\server.bat start alias stopOpenLiberty1901= C:\Development\Server\OpenLiberty\openliberty-184.108.40.206\bin\server.bat stop alias startWildFly16= C:\Development\Server\Wildfly\wildfly-16.0.0\bin\standalone.bat -Djboss.http.port=8888 alias startTomEEPlume= C:\Development\Server\TomEE\apache-tomee-plume-8.0.0-M2\bin\catalina.bat run
With this tooling, you can now pick any Editor (Visual Code, Atom, Notepad++ ...) or IDE of your choice and start coding. When you save your changes they will be automatically deployed and you can see the results after a short delay (1 – 3 seconds, depending on how thin your
.war is) in your browser.
If you are looking for a Docker-based solution in combination with WAD, have a look at this excellent video of Sebastian Daschner.
You can find a quick example of using WAD in my GitHub repository.
Happy Java EE hacking,