wildfly deploy war using CLI and Management Console

WildFly has several configuration options and ways to deploy applications. For both administrators and developers, the CLI and management console offer several options. Here we have used the standalone mode of wildfly for the same. Here we will discuss about two types of deployment techniques

 

  1. Standalone mode
  2. Domain mode

 

Standalone mode:

Deploying Through CLI

Installation of applications using the CLI provides advantages of owning a single command-line interface that allows us to run installation scripts for specific scenarios. You can manage the status of the deployment of a single server or all servers that make up the domain.

Access the CLI using the following command:

[[email protected] bin]# ./jboss-cli.sh --connect --controller=192.168.11.109:9990

[[email protected]:9990 /]

 

To deploy, just use the deploy command, passing the application location in the filesystem as a parameter. For the following example, we use the application app1-v01:

 

[[email protected]:9990 /] deploy app1-v01.war

 

The output of the preceding command is as follows:

 

JBAS015876: Starting deployment of "app1-v01.war" (runtime-name:"app1-v01.war")

JBAS017534: Register web context: /app1-v01

JBAS018559: Deployed "app1-v01.war" (runtime-name : "app1-v01.war")

 

The application is now available at http://<ip-address>:8080/app1-v01/.

 

To undeploy the application using the CLI, just use the undeploy command followed by the name of the artifact. The CLI has the autocomplete attribute. If you do not remember the full name of the artifact, just press Tab to use the autocomplete attribute.

 

[[email protected]:9990 /] undeploy app1-v01.war

 

In the logs, we can see that the undeploy command was successfully completed as follows:

 

JBAS017535: Unregister web context: /app1-v01

JBAS015877: Stopped deployment app1-v01.war (runtime-name: app1-v01.war) in 3566ms

JBAS014901: Content removed from location /opt/server/wildfly-8.1.0.CR1/standalone/data/content/24/ec8acdc2610bc6b4a59d3736274d7659a21177/content

JBAS018558: Undeployed "app1-v01.war" (runtime-name: "app1-v01.war")

 

Deployment using management console

Performing the deployment through the management console provides some advantages; the main one is ease of use.

1. To begin, access the management console.

2. Click on the Runtime tab and click on Manage Deployments, as shown in the following screenshot:

WildFly Deployment using management console

3. The preceding page displays all active deployments. In this case, we do not have any deployment; we’ll add the first deployment. For this, click on the Add button and select the artifact to perform the deploy. In my case, I copied the artifact application, app1-v01, for my test machine desktop as shown in the following screenshot:

WildFly Deployment using management console

4. When you click on Next, the upload of the artifact will be performed. On the next page, change only the Name and Runtime Name values if desired. The Name parameter is the name that the application will have, and it will be used for access through a web browser. The Runtime Name parameter is the name that the application will run within the environment.

WildFly Deployment using management console

5. Click on Save and you can see that the application is on the server but is still inactive, as shown in the following screenshot:

WildFly Deployment using management console

6. To activate the deploy and make the application available, select the application and click on the En/Disable button to activate it and then click on Confirm to confirm the action, as shown in the following screenshot:

WildFly Deployment using management console

7. After the request is completed, you can check the logs that show the completion of the deployment. At this time, the application is now available for access; check the logs as follows:

JBAS015876: Starting deployment of "app1-v01.war" (runtime-name:"app1-v01.war")


JBAS017534: Register web context: /app1-v01


JBAS018559: Deployed "app1-v01.war" (runtime-name :"app1-v01.war")

8. To disable the application, just click on the same button that you used to activate the deployment. Now, let’s remove the application from our server. Select the application you want to remove, and click on the Remove button, and then on the Confirm button to confirm the request as shown in the following screenshot:

WildFly Deployment using management console

 

9. On completion of the request, we can see in the logs that the undeploy command was successful as follows:

JBAS015877: Stopped deployment app1-v01.war (runtime-name: app1-v01.war) in 119ms


JBAS018558: Undeployed "app1-v01.war" (runtime-name: "app1-v01.war")


JBAS014901: Content removed from location /opt/server/wildfly-8.0.0.CR1/standalone/data/content/24/ds2c8acdc2610bc6b4a59d3736274d7659a21177/content

Domain Mode:

Deployment using the CLI

Once logged in to the CLI, run the following command to perform the deployment:

[[email protected]:9990 /] deploy /opt/myappmach/app1-v02/target/app1-v02-0.0.1-SNAPSHOT.war --all-server-groups

Wait until the execution completes so that we can easily verify the completion of the deployment via the management console, as shown in the following screenshot:

WildFly Content Repository

 

The output is as follows:

[Server:server-two] 18:04:18,088 INFO [org.wildfly.extension.undertow] (MSC service thread 1-1) JBAS017534: Register web context: /


[Server:server-two] 18:04:19,780 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "app1-v02-0.0.1-SNAPSHOT.war" (runtime-name : "app1-v02-0.0.1-SNAPSHOT.war")


[Server:server-two] 18:04:24,837 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.0.0.CR1 "WildFly" started in 78666ms - Started 301 of 353 services (94 services are lazy, passive or on-demand)


[Server:server-one] 18:04:35,469 INFO [org.wildfly.extension.undertow] (MSC service thread 1-2) JBAS017534: Register web context: /


[Server:server-one] 18:04:36,506 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS018559: Deployed "app1-v02-0.0.1-SNAPSHOT.war" (runtimename: "app1-v02-0.0.1-SNAPSHOT.war")

To undeploy using the CLI, just execute the following command:

[[email protected]:9990 /] undeploy app1-v02-0.0.1-SNAPSHOT.war--allrelevant-server-groups

 

deployment using the management console

 

For the domain mode deployment using the management console, you need to start WildFly in the domain mode. For this, run the following command:

[[email protected] ~]# /opt/server/wildfly-8.0.0.CR1/bin/domain.sh

Once WildFly is running, open the management console, the procedure and the user are the same used in the previous example for the standalone mode.

To start the deployment, perform the following steps:

1. Click on Manage Deployments, and then on Add as shown in the following screenshot:

WildFly Manage Deployment Screen

2. Now, select the file to perform the deploy, and then click on Next, as shown in the following screenshot:

WildFly Deployment Selection

3. Then, just click on Save as shown in the following screenshot:

Wildfly Verify Deployment Screen

4. After the artifact is added, it is necessary to assign the deployment to a server group. For this, click on the server groups, and then on Assign:

Wildfly Deployments in group

 

5. Now, you need to select the artifact. We will select the artifact that we added earlier, and then click on Save, as shown in the following screenshot:

WildFly Server Group Screen

6. And lastly, you must enable the deployment. For this, select the artifact and click on En/Disable as shown in the following screenshot:

Wildfly Deployment in Group screen

7. Confirm the action and wait till the end of the deployment.

8. The deployment will be carried out for all instances that are part of the group server. Check the following logs and notice that the deployment was performed:

[Server:server-two] 16:52:49,559 INFO [org.jboss.as.server] (host-controller-connection-threads - 4) JBAS018559: Deployed "app1-v01.war" (runtime-name : "app1-v01.war")


[Server:server-one] 16:52:49,335 INFO [org.jboss.as.server] (host-controller-connection-threads - 4) JBAS018559: Deployed "app1-v01.war" (runtime-name : "app1-v01.war")

9. And to undeploy, just click on En/Disable again.

 

This completes the steps to deploy an application using CLI and management console in standalone mode and domain mode.

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

5 Responses

  1. Tom Cat says:

    Can I run *war aplication which is running on tomcat in wildfly? Wouldby there any performance benefit?

  2. The correct command to undeploy form the domain is
    “undeploy war-file-name.war –all-relevant-server-groups”

    • Hi Rajesh.. Thanks for the command. The command to undeploy varies depending on type of deployment which you want to undeploy… As stated in article there are two types domain mode and standalone mode.

      Like.. all-relevant-server-groups command is applicable for removing binaries from server groups in domain mode with the undeploy command:

      [[email protected]:9999 /] undeploy test-application.war –all-relevant-server-groups
      Successfully undeployed test-application.war.

      But when it comes to standalone mode you don’t need to use the server groups flag.Deployments on a standalone server work in a similar way to those on managed domains. The main difference between domain and standalone is that there are no server group associations.

      [[email protected]:9999 /] undeploy test-application.war
      Successfully undeployed test-application.war.

Leave a Reply