Bookmark this page

Deploying Applications to a Standalone Server

Objectives

  • Deploy a Jakarta EE application to a JBoss EAP instance running as a standalone server.

The Deployments Section of the standalone.xml File

The <deployments> section of the standalone.xml configuration file defines the deployed applications on the standalone server. The <deployments> element contains a single <deployment> child element.

Here is an example of a <deployments> section:

<deployments>
  <deployment name="kitchensink.war" runtime-name="kitchensink.war">
      <content sha1="f9418ea27525e0f3c02ea099405265246b22b55a"/>
  </deployment>
  <deployment name="temperature-converter.war" runtime-name="temperature-converter.war">
      <content sha1="555df23b973ed9f76f7c817deec3bab6a13a7ea3"/>
  </deployment>
  <deployment name="numberguess.war" runtime-name="numberguess.war">
      <fs-exploded path="/opt/apps/numberguess.war"/>
  </deployment>
</deployments>

In the example above, there are three applications deployed: kitchensink.war, temperature-converter.war, and numberguess.war. The first two applications are managed by JBoss EAP. The numberguess.war application is deployed by using the unmanaged method.

The <content> element represents a secure hash algorithm (SHA) value of the deployment file, and is the unique identifier for the deployment.

The managed deployments are stored in the BASE_DIR/data/content directory which is the deployment cache directory. For example, if your JBoss EAP instance is in the /opt/jboss/my-instance directory, then the managed deployments are in the /opt/jboss/my-instance/data/content directory.

JBoss EAP creates a directory in which the name is defined by the first two characters of the SHA1 code. Inside this directory, another subdirectory is created. The name of this subdirectory is the remaining characters of the SHA1 code.

For the deployments listed above, the following directory should be available:

[student@workstation labs]$ tree -d JBOSS_HOME/standalone/data/content/
standalone/data/content/
├── 55
│   └── 5df23b973ed9f76f7c817deec3bab6a13a7ea3
└── f9
    └── 418ea27525e0f3c02ea099405265246b22b55a

The numberguess.war application is deployed by using the unmanaged approach. Therefore, its files are not present in the $JBOSS_HOME/standalone/data/content directory.

Note

Red Hat does not recommend adding a <deployment> element to the <deployments> section of a JBoss EAP configuration manually. However, it is possible to delete entries manually, and restart the server to undeploy an application.

Deploying Applications with Management Tools

The deploying process is responsible for installing an application in JBoss EAP. This includes the copy of the package, and also the configurations that should be executed in the server.

There are three ways to deploy an application to a standalone server:

  • The management console

  • The management CLI

  • The file system deployer

Deploying by Using the Management Console

The management console has a section to manage the deployments available in the standalone server. This section is available in the management console, in the Deployments menu at the top of the page.

Figure 3.1: Deployments view

You can create a deployment by clicking Add, to start the deployments wizard. The first step of the wizard asks for the type of the deployment. Three options are available:

Upload Deployment

By using this option, you upload an application. This upload makes the application available in the JBOSS_HOME/standalone/data/content directory, and adds a <deployment> element in the standalone.xml configuration file.

Add Unmanaged Deployment

By using this option, a path must be specified to where the application archive is available. It is called unmanaged because JBoss EAP does not persist the application in the deployment cache, and any user who has permission to the configuration file can remove it.

Create Empty Deployment

By using this option, JBoss EAP creates an empty deployment in an directory with the same structure of an enterprise application archive (EAR), or a web application archive (WAR). You can test deployments by copying individual files to that directory.

You can upload the application file by using the Upload Deployment option. You can select a file from your local file system, or drag and drop the application file.

Figure 3.2: Selecting deployment file

The next step on the wizard has three options to be defined:

Name

Identifies the deployment. It must be a unique value across all deployments.

Runtime Name

Identifies the deployment internally within the server runtime. JBoss EAP bases internal names for application modules, such as EJB names, in this runtime name. It is common that the value for Name, and Runtime Name are the same.

Enabled

Defines if the deployment should start immediately. If it is not checked, then it is possible to enable it later.

Enabling and Disabling a Deployment by Using the Management Console

An application can be configured to start during the startup of JBoss EAP. Configure the deployment as enabled if it should start during JBoss EAP startup.

You can enable and disable a deployment in the management console by using the Deployments menu.

To disable an application, click the application. A combo box shows. Clicking the down arrow, the Disable option is displayed.

Figure 3.3: Disabling a deployed application

Click Disable and then, in the confirmation screen, click Confirm to disable the deployment.

To enable a deployment, click the application and the combo box shows again. Click the down arrow to see the Enable option.

Figure 3.4: Enabling an application

Click Enable and then, in the confirmation screen, click Confirm to enable the deployment.

Undeploying an Application Using the Management Console

You can undeploy applications in the management console by using the Deployments menu. menu. To undeploy an application, click the application. A combo box shows. Click the down arrow, to see the Remove option.

Click Remove and then, in the confirmation screen, click Confirm to undeploy the application.

Note

Undeploying is different from disabling a deployment. Undeploying uninstalls the application from JBoss EAP by removing the application from the server. If you disable an application, then the server does not start it, but the application remains available to enable again.

Deploying Using the Management CLI

The management CLI provides the deploy command to start a deployment. The following is a list of arguments for the deploy command:

file_path

Path to the application to deploy.

--url

URL at which the deployment content is available for upload to the deployment content repository.

--name

The unique name of the deployment. If no name is provided, then the file name is used.

--runtime-name

Optional, defines the runtime name for the deployment.

--force

If the deployment with the specified name already exists, by default, then the deployment is aborted and the corresponding message is printed. The --force, or -f argument forces the replacement of the existing deployment with the one specified in the command arguments.

--disabled

Indicates that the deployment is added to the repository, but in a disabled state.

To deploy an application that is located at /home/student/myapp.war use the following command:

[standalone@localhost:19990 /] deploy /home/student/myapp.war --name=myapp.war

Undeploying Using the Management CLI Tool

The management CLI provides the undeploy command to remove a deployment. The following is a list of arguments for the undeploy command:

name

The name of the application to undeploy.

--keep-content

Disable the deployment but do not remove its content from the repository.

[standalone@localhost:19990 /] undeploy myapp.war

Deploying Applications by Using the File System Deployer

The file system deployer is a JBoss EAP subsystem that scans for Jakarta EE compliant applications at a specific directory.

The standalone server mode supports deployment of applications manually. You can copy the application to the JBOSS_HOME/standalone/deployments directory to manually start a deployment.

The deployment process is managed using marker files. A marker file is an empty file that uses the same name as the application, and adds the objective of the marker file to the end of the file name. The marker file is created in the deployments directory. You can use the following marker files extensions:

.dodeploy

It is created by the user. It triggers a new deployment of the application.

.deployed

It is created by the deployment scanner. It indicates that the application has been deployed.

.isdeploying

It is created by the deployment scanner. It indicates that the application is deploying.

.failed

It is created by the deployment scanner. It indicates that the application has failed.

.isundeploying

It is created by the deployment scanner. It indicates that the application is undeploying.

.undeployed

It is created by the deployment scanner. It indicates that the application has been undeployed.

.skipdeploy

It is created by the user. It indicates that the application should not be deployed.

.pending

It is created by the deployment scanner. It indicates that it has noticed the need to deploy content but has not yet instructed the server to deploy it.

To deploy an application named myapp.war, create the myapp.war.dodeploy marker file.

Red Hat recommends to disable the file system deployer in productive environments.

References

For more information about deploying applications, refer to the Deploying Applications chapter in the Configuration Guide in the in the Red Hat JBoss EAP 7 documentation at https://access.redhat.com/documentation/en-us/red_hat_jboss_enterprise_application_platform/7.4/html-single/configuration_guide/index#deploying_applications

JBoss EAP Quickstarts repository containing the example applications

Revision: ad248-7.4-18a9db2