WildFly provides multiple ways to deploy to your applications.
So far we’ve seen:
- Curl (Tech Tip #10)
- Maven plugin (Tech Tip #9)
- NetBeans (Tech Tip #6)
- JBoss Tools/Eclipse (Tech Tip #5)
- IntelliJ (Tech Tip #4)
This tip will cover the most likely way to deploy deploy applications to WildFly, i.e. jboss-cli.
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.
Lets look at interactive first:
- Use jboss-cli to connect with the existing standalone instance by giving the following command:
123jboss-cli.sh -c-c
switch connects using the default host (‘localhost’) and management port (‘9990’). These values are specified in ‘bin/jboss-cli.xml’ and can be updated.This opens up the “jboss-cli” interactive console and shows the following prompt:
123[standalone@localhost:9990 /]The prompt indicates that ‘jboss-cli’ is connected to a standalone instance’s management port.
- Deploy the application by giving the following command in console:
123deploy target/javaee7-1.0-SNAPSHOT.war
The directory name of the war file in the command may be different depending upon how ‘jboss-cli’ was invoked. Verify the server log to ensure that the application was redeployed. Look for specific timestamp in the log entries.
--force
switch can be included in the command to replace the existing application. - Verify the deployment status by typing the following command
deployment-info
in the console:123deployment-infoand see the output as:
1234NAME RUNTIME-NAME PERSISTENT ENABLED STATUSjavaee7-1.0-SNAPSHOT.war javaee7-1.0-SNAPSHOT.war true true OKVerify the server log to ensure that the application was deployed. Look for specific timestamp in the log entries.
- Undeploy the application by giving the following command:
123undeploy javaee7-1.0-SNAPSHOT.war
- Type “exit” or “quit” to exit the interactive console.
Now lets look at how these commands can be issued non-interactively very easily.
- Deploy the application as:
123jboss-cli.sh --connect --command="deploy target/javaee7-1.0-SNAPSHOT.war --force" - Verify the deployment status as:
123./bin/jboss-cli.sh --connect --command=deployment-info
- Undeploy the application as:
123./bin/jboss-cli.sh --connect --command="undeploy javaee7-1.0-SNAPSHOT.war"