Red Hat Training

A Red Hat training course is available for Red Hat JBoss Operations Network

4. Deploying Applications on Application Servers

Applications such as EAR and WAR files that are deployed on an application server are cross between a child resource (of the application server) and content that is managed in a repository.
For these content-backed resources, the child resource is created first, by uploading a package to the JBoss server. After that, they are managed like content, with updated packages added to a content repo and then applied to the application server.

4.1. Setting Permissions for Agent and Resource Users

The assumption is that the JBoss ON agent and resources like a JBoss server or Tomcat server run as the same system user. This allows the agent and the application server itself to manage resource content and configuration simultaneously.
However, if the agent user is different than the resource user, then there can be problems when one entity makes a configuration change and the other attempts a change later.
For example, when deploying an application, the deployment operation is initiated by the agent and the content is supplied through the agent, and then the application server completes the actual deployment. When deleting an application, the application server handles the undeployment by itself.
If a WAR file is deployed exploded without a MANIFEST.MF file, the agent creates one when it writes the SHA-256 value for the package. When the JBoss AS server tries to remove the WAR application later (and the JBoss AS user is different than the agent user), then the removal fails. The JBoss AS server cannot delete the MANIFEST.MF file. The agent then rediscovers the application directory and re-initiates the deployment operation for the removed WAR.

Note

This situation only occurs when the application is exploded and does not contain the MANIFEST.MF file — meaning, a situation where the agent creates a file within the deployment directory. Even if the agent and JBoss AS users are different, this situation does not occur if the application is not exploded or where the agent does not write any files.
This situation can be avoided. If the agent user and resource user are different, then change the system settings:
  1. Add the agent user and the resource user to the same primary group.
  2. Set the umask value for the agent user to give read and write permissions, such as 660. For example:
    vim /home/rhqagent/.bashrc
    
    umask 660

4.2. Deploying EAR and WAR Files

  1. Search for the JBoss server instance to which to deploy the EAR or WAR.
  2. On the details page for the selected JBoss server instance, open the Inventory tab.
  3. In the Create New menu at the bottom, select the item for - Web Application (WAR) or - Enterprise Application (EAR), as appropriate.
  4. Enter the version number.
    This is not used for the resource. The actual version number is calculated based on the spec version and implementation version in MANIFEST.MF, if any are given, or the caluclated SHA-256 value for the package itself:
    SPEC(IMPLMENTATION)[sha256=abcd1234]
    If no version numbers are defined in MANIFEST.MF, then the SHA value is used. The SHA value is always used to identify the package version internally.

    Note

    When the EAR or WAR file is exploded after it is deployed, the MANIFEST.MF file is updated to include the calculated SHA version number. For example:
    Manifest-Version: 1.0
    Created-By: Apache Maven
    RHQ-Sha256: 570f196c4a1025a717269d16d11d6f37
    ...
    For more information on package versioning, see "Deploying Applications and Content".
  5. Upload the EAR/WAR file.
  6. Enter the information for the application to be deployed.
    • Whether the file should be exploded (unzipped) when it is deployed.
    • The path to the directory to which to deploy the EAR or WAR package. The destination directory is relative to the JBoss server instance installation directory; this cannot contain an absolute path or go up a parent directory.
    • Whether to back up any existing file with the same name in the target directory.
Once the EAR/WAR file is confirmed, the new child resource is listed in the Child History subtab of the Inventory tab.
WAR Child Resource

Figure 10. WAR Child Resource

4.3. Updating Applications

After the EAR or WAR resource is created, changes are treated like updated content packages. Updating the EAR/WAR resource is the same as uploading and applying new packages to that EAR/WAR resource entry.
  1. Browse to the EAR or WAR resource in the JBoss ON UI.
  2. In the EAR or WAR resource details page, open the Content tab, and click the New subtab.
  3. Click the UPLOAD NEW PACKAGE button.
  4. Click the UPLOAD FILE button.
  5. In the pop-up window, click the Add button, and browse the local filesystem to the updated WAR or EAR file to be uploaded.
  6. Click the UPLOAD button to load the file and dismiss the window.
  7. In the main form, select the repository where the WAR or EAR file package should be stored. If one exists, select an existing repository or a subscribed repository for the resource. Otherwise, create a new repository.
  8. Optionally, set the version number for the EAR/WAR package.
    If this is set, then this value is displayed in the UI. If not, then a version number is calculated, based on the spec version and implementation version in MANIFEST.MF, if any are given, or the calculated SHA-256 value for the package itself. Internally, the package is identified by the SHA value.
    SPEC(IMPLMENTATION)[sha256=abcd1234]
    For more information on package versioning, see "Deploying Applications and Content".
  9. Confirm the details for the new package, then click CONTINUE.
When the package is successfully uploaded, the UI redirects to the history page on the Content tab.
Deployment History for a Resource

Figure 11. Deployment History for a Resource

4.4. Deleting an Application

Deleting an EAR/WAR application is the same as deleting the currently deployed package associated with that EAR/WAR resource entry.
  1. Browse to the EAR or WAR resource in the JBoss ON UI.
  2. In the EAR or WAR resource details page, open the Content tab, and click the Deployed subtab.
  3. Select the checkbox by the EAR/WAR package, and click the DELETE SELECTED button.