Deploying applications on a JBoss AS domain
Deploying applications in a JBoss domain cannot be achieved with a single cut-and-paste operation like for standalone domains. As a matter of fact, there’s no predefined deployments folder in the domain installation. The reason for this is because in the domain mode, there can be many servers belonging to different server groups, each one running different profiles. In that situation, a single deployments folder would raise the obvious question: which server groups will be using that folder? This requires some knowledge that the AS deployment scanner cannot have.
So, basically, a deployment on a JBoss AS domain can be performed using the following set of options:
- Using the Command Line interface
- Using the Admin Web interface
Here’s a complete outline of both approaches:
Deploying to an AS domain using the CLI
Start by launching the CLI and connect to the domain controller:
[disconnected /] connect Connected to domain controller at localhost:9999
When you are deploying an application using domain mode, you have to specify to which server group the deployment is associated. The CLI lets you choose between two options:
- Deploy to all server groups.
- Deploy to a single server group.
We discuss the options in two separate sections.
Deploy to all server groups
When choosing this option, the application will be deployed to all the available server groups. The –all-server-groups flag can be used for this purpose.
For example: [domain@localhost:9999 /]
deploy ../application.ear –all-
If, on the other hand, you want to un-deploy an application from all server groups belonging to a domain, you have to issue the undeploy command:
[domain@localhost:9999 /] undeploy application.ear –all-relevant-server-groups
Successfully undeployed application.ear
You might have noticed that the undeploy command uses the –all-relevant-server-groups instead of –all-server-groups. The reason for this difference is that the deployment may not be enabled on all server groups, so by using this option, you will actually un-deploy it just from all the server groups in which the deployment is enabled.
Deploy to a single server group
The other option lets you perform a selective deployment of your application, just on the server groups you have indicated.
deploy application.ear –server-groups=main-server-group Successfully deployed application.ear
You are not limited to a single server group, but you can separate multiple server groups with a comma; for example:
[domain@localhost:9999 /] deploy application.ear –server-groups=main-server-group,other-server-group Successfully deployed application.ear
Now, suppose we want to un-deploy the application from just one server group. There can be two possible outcomes. If the application is available just on that server group, you will successfully complete the un-deployment:
[domain@localhost:9999 /] undeploy
Successfully undeployed as7project.war.
On the other hand, if your application is available on other server groups, the following error will be returned by the CLI:
It seems that something went wrong. As a matter of fact, when you are removing an application from a server group, the domain controller checks that the application is not referenced by any other server group, otherwise the previous command will fail.
You can, however, instruct the domain controller to un-deploy the application, without deleting the content also:
[domain@localhost:9999 /] undeploy
group –keep-content Successfully undeployed
So, we have learnt quite a lot of available options to deploy applications in a domain. Before moving to the admin console, let’s review the CLI deployment options:
Deploying to an AS domain using the Admin console
Deploying applications using the Admin console is pretty intuitive and requires just a few simple steps. Start by logging into the Web application at the default address: http://localhost:9990/console.
Then, select the Runtime tab (Point 1 in the screenshot). You will see that in the left panel of the screen, there’s a Deployments menu, which includes the option Manage Deployments (Point 2).
From there, you can use the tabbed menu named Server Groups (Point 3) to check which applications are deployed on the single server groups.
The application can be uploaded using the Add Content button (Point 4), which introduces you to the next dialog:
Once you are done with the upload wizard, the application will be uploaded to the domain repository. In order to deploy/un-deploy it to the single server groups, you should select first the server group (Option 1) on which you want to operate, and then click the Add to Group (Option 2) button.
At this point, the application is deployed but still not enabled. Choose the Enable button to complete the deployment of the application.
The Remove button within the Server-Groups area will remove the deployment from the server group selected, while the other Remove button within the Content Repository will actually delete it from the temporary domain repository where uploaded applications are bundled.