Deployment is the process of uploading resources or applications into the application server. In the software production cycle, it’s the step that logically follows the development phase and can be performed either manually or in an automated fashion, using scripts.
In this tutorial, we will explore both approaches using the set of tools that are part of the server distribution. We will also cover how to deploy resources on the applications server using the Eclipse development environment, which is the preferred choice of JBoss AS developers.
In the last part of this chapter, we provide details about the new JBoss AS classloader architecture. In short, our agenda for this chapter includes the following topics:
Deploying resources on the application server
There are basically three file types that we work with in Java Enterprise applications:
1. JAR file: This is the most basic package that can be used for both application and common resources.
2. WAR file: This archive is used for packaging web applications.
3. EAR file: This package acts as a container for Enterprise applications.
Besides these, JBoss AS is able to process the following archives, which provides additional functionalities to the application server.
RAR file: This is a resource adapter file, which is used to define a resource adapter component (the resource adapter subsystem is provided by IronJacamar project; for more information, look here: https://www.jboss.org/ironjacamar)
SAR file: This enables the deployment of Service Archives containing MBean Services, as supported by previous versions of the application server
In this chapter, we will discuss the first three kinds of archives, which constitute the typical packaging solution for Java Enterprise applications. Before discussing application deployment, let’s see the single archives a bit more in detail.
The JAR archive
A Java Archive (JAR) file is used for organizing many files into one. The actual internal physical layout is much like a ZIP file, and as a matter of fact, it uses the same algorithm as the zip utility for compressing files.
A JAR is generally used to distribute Java classes and associated metadata. In Java EE applications, the JAR file often contains utility code, shared libraries, and EJBs.
The WAR archive
A Web Application Archive (WAR) file is essentially an archive used to encapsulate a web application. The web application usually includes a collection of Java Server Pages (JSP), Servlets, Java classes, XHTML, and HTML files, plus other file types, depending on the technology used.
Since Java EE 6, a web application is now able to package EJBs in a WAR, using the same packaging guidelines that apply to web application classes. This means that you can place EJB classes under the WEB-INF/classes directory or as a JAR file within the WEB-INF/lib directory.
Because of this, it’s expected that developers will use the WAR archive as the most common type of archive to distribute Java EE 6 applications.
The EAR archive
An Enterprise Archive (EAR) file represents an application archive, which acts as a container for a set of modules. An EAR file can contain any the following:
The advantage of using an Enterprise Archive file is two-fold: at first, it helps to distribute all applications components using a single archive, instead of distributing every single module. Second, and most important, is the fact that applications within an EAR archive will be loaded by a single classloader. Thus, by default, each module will have visibility on other modules packed in the archive.
The isolation level of applications modules contained in the EAR archive is controlled by the ear-subdeployments-isolated element of the main configuration file (standalone.xml/domain.xml).
In the section of this tutorial named JBoss AS 7 classloading explained, we will discuss in depth the application server classloading architecture, also showing how to override this configuration setting at application level.
Get Updates on Tech posts, Interview & Certification questions and training schedules