
WildFly is a free, open source & cross platform application server (formely known as Jboss AS or Jboss). It is written in java programming language & currently it is being maintained, developed by Redhat. It is one of the most popular application servers among Java EE programmers all around the world.
WildFly provides multiple ways to deploy your applications. In this post, we will deploy applications to remote WildFly using jboss-cli
. See my other posts to learn the other ways to do it.
- Deploy applications to a remote WildFly Server using jboss-cli-client.jar
- Deploy applications to a remote WildFly server using curl
- Deploy applications to WildFly server using wildfly maven plugin
jboss-cli is Command Line Interface management tool for a standalone server or a managed domain. It is available in the bin directory of unzipped WildFly distribution and allows a user to connect to a standalone server or domain controller and execute management operations. jboss-cli
can be used to deploy applications using the interactive console or in a non-interactive manner.
For deploying applications to remote WildFly server, you need to have WildFly distribution in the client machine. Download the latest stable version from WildFly official download page and extract in a directory of your preference.
Now go to the bin directory of unzipped WildFly distribution. To install applications in remote WildFly, run:
./jboss-cli.sh --connect --controller=<REMOTE_WILDFLY_IP>:9990 --user=<USERNAME> --password=<PASSWORD> --command="deploy /PATH/TO/test.war"
Here, --controller
parameter does the trick. It is used to connect to remote WildFly server and run command on that. --user
and --password
parameters takes the management username, password of the remote WildFly for authentication purpose. command
parameter takes the command to run; here, our command is to deploy a test.war file. You can send any jboss-cli
supported command to remote WildFly using this method.
If the application is already deployed, you will get a failure response:
org.jboss.as.cli.CommandFormatException: 'test.war' already exists in the deployment repository (use --force to replace the existing content in the repository).
In that case, you need to add --force
in the command to replace the existing content in the wildfly repository
./jboss-cli.sh --connect --controller=<REMOTE_WILDFLY_IP>:9990 --user=<USERNAME> --password=<PASSWORD> --command="deploy /PATH/TO/test.war --force"
Or you can undeploy the application before new deployment:
./jboss-cli.sh --connect --controller=<REMOTE_WILDFLY_IP>:9990 --user=<USERNAME> --password=<PASSWORD> --command="undeploy test.war"
To know the deployment status, run:
./bin/jboss-cli.sh --connect --controller=<remote_wildfly_ip>:9990 --user=<username> --password=<password> --connect --command="deployment-info"
And the output should be:
NAME RUNTIME-NAME PERSISTENT ENABLED STATUS test.war test.war true true OK
That’s it! Now your application is deployed and enabled in the remote WildFly server instance using jboss-cli
.